public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature
@ 2023-01-18 13:57 Markus Frank
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Markus Frank @ 2023-01-18 13:57 UTC (permalink / raw)
  To: pve-devel

qemu-server:

v5:
* set $kvm to 1 if is_native, so that api kvm check works.

v4:
* added kvm/q35 checks in API
* reused pve-qemu-machine

v3:
* replaced old machine type with property-string with viommu-parameter

v2:
* moved viommu-parameter inside of machine_fmt and added it the new
parameter machine_properties
new Config -> machine_properties: viommu=1,etc
* check if kvm and q35 are set


Markus Frank (3):
  tests: replaced somemachine&someothermachine with q35&pc
  fix #3784: Parameter for guest vIOMMU & machine as property-string
  added test-cases for new machine-syntax & viommu

 PVE/API2/Qemu.pm                              | 23 ++++++--
 PVE/QemuConfig.pm                             |  3 +-
 PVE/QemuServer.pm                             | 52 +++++++++++++++++--
 PVE/QemuServer/Machine.pm                     |  6 ++-
 test/cfg2cmd/q35-viommu-alt.conf              |  1 +
 test/cfg2cmd/q35-viommu-alt.conf.cmd          | 23 ++++++++
 test/cfg2cmd/q35-viommu.conf                  |  1 +
 test/cfg2cmd/q35-viommu.conf.cmd              | 23 ++++++++
 .../commit/qemu-server/101.conf               |  2 +-
 .../commit/qemu-server/102.conf               |  2 +-
 .../commit/qemu-server/201.conf               |  2 +-
 .../commit/qemu-server/202.conf               |  2 +-
 .../commit/qemu-server/203.conf               |  2 +-
 .../create/qemu-server/102.conf               |  2 +-
 .../create/qemu-server/104.conf               |  4 +-
 .../create/qemu-server/106.conf               |  2 +-
 .../create/qemu-server/301.conf               |  2 +-
 .../create/qemu-server/302.conf               |  2 +-
 .../delete/qemu-server/203.conf               |  2 +-
 .../delete/qemu-server/204.conf               |  2 +-
 .../prepare/qemu-server/102.conf              |  2 +-
 .../prepare/qemu-server/104.conf              |  2 +-
 .../rollback/qemu-server/101.conf             |  2 +-
 .../rollback/qemu-server/106.conf             |  4 +-
 .../rollback/qemu-server/201.conf             |  2 +-
 .../rollback/qemu-server/202.conf             |  2 +-
 .../rollback/qemu-server/203.conf             |  2 +-
 .../rollback/qemu-server/204.conf             |  2 +-
 .../rollback/qemu-server/205.conf             |  2 +-
 .../rollback/qemu-server/301.conf             |  2 +-
 .../rollback/qemu-server/302.conf             |  2 +-
 .../rollback/qemu-server/303.conf             |  2 +-
 .../commit/qemu-server/101.conf               |  2 +-
 .../commit/qemu-server/102.conf               |  2 +-
 .../commit/qemu-server/201.conf               |  2 +-
 .../commit/qemu-server/202.conf               |  2 +-
 .../commit/qemu-server/203.conf               |  2 +-
 .../create/qemu-server/104.conf               |  2 +-
 .../delete/qemu-server/101.conf               |  2 +-
 .../delete/qemu-server/203.conf               |  2 +-
 .../delete/qemu-server/204.conf               |  2 +-
 .../rollback/qemu-server/101.conf             |  2 +-
 .../rollback/qemu-server/102.conf             |  2 +-
 .../rollback/qemu-server/103.conf             |  2 +-
 .../rollback/qemu-server/104.conf             |  2 +-
 .../rollback/qemu-server/106.conf             |  4 +-
 .../rollback/qemu-server/201.conf             |  2 +-
 .../rollback/qemu-server/202.conf             |  2 +-
 .../rollback/qemu-server/203.conf             |  2 +-
 .../rollback/qemu-server/204.conf             |  2 +-
 .../rollback/qemu-server/205.conf             |  2 +-
 .../rollback/qemu-server/301.conf             |  2 +-
 .../rollback/qemu-server/302.conf             |  2 +-
 .../rollback/qemu-server/303.conf             |  2 +-
 test/snapshot-test.pm                         |  2 +-
 55 files changed, 173 insertions(+), 59 deletions(-)
 create mode 100644 test/cfg2cmd/q35-viommu-alt.conf
 create mode 100644 test/cfg2cmd/q35-viommu-alt.conf.cmd
 create mode 100644 test/cfg2cmd/q35-viommu.conf
 create mode 100644 test/cfg2cmd/q35-viommu.conf.cmd


docs:

v5:
* changed Host and VM Requirements

Markus Frank (1):
  added vIOMMU documentation

 qm-pci-passthrough.adoc | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)


manager:

v5:
* added check if kvm is undefined or null

v4:
* check if kvm is enabled
* added kvm+q35 hint

Markus Frank (1):
  ui: MachineEdit with viommu checkbox

 www/manager6/qemu/MachineEdit.js | 58 ++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc
  2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
@ 2023-01-18 13:57 ` Markus Frank
  2023-08-17 11:43   ` [pve-devel] applied: " Fiona Ebner
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 2/5] feature #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Markus Frank @ 2023-01-18 13:57 UTC (permalink / raw)
  To: pve-devel

needed for new machine parameter

parse_property_string checks for the regex, therefore the test-cases
with somemachine & someothermachine always fail.

So I changed somemachine & someothermachine to q35 & pc with sed

sed -i 's/somemachine/q35/g'
sed -i 's/someothermachine/pc/g'

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 test/snapshot-expected/commit/qemu-server/101.conf   | 2 +-
 test/snapshot-expected/commit/qemu-server/102.conf   | 2 +-
 test/snapshot-expected/commit/qemu-server/201.conf   | 2 +-
 test/snapshot-expected/commit/qemu-server/202.conf   | 2 +-
 test/snapshot-expected/commit/qemu-server/203.conf   | 2 +-
 test/snapshot-expected/create/qemu-server/102.conf   | 2 +-
 test/snapshot-expected/create/qemu-server/104.conf   | 4 ++--
 test/snapshot-expected/create/qemu-server/106.conf   | 2 +-
 test/snapshot-expected/create/qemu-server/301.conf   | 2 +-
 test/snapshot-expected/create/qemu-server/302.conf   | 2 +-
 test/snapshot-expected/delete/qemu-server/203.conf   | 2 +-
 test/snapshot-expected/delete/qemu-server/204.conf   | 2 +-
 test/snapshot-expected/prepare/qemu-server/102.conf  | 2 +-
 test/snapshot-expected/prepare/qemu-server/104.conf  | 2 +-
 test/snapshot-expected/rollback/qemu-server/101.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/106.conf | 4 ++--
 test/snapshot-expected/rollback/qemu-server/201.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/202.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/203.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/204.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/205.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/301.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/302.conf | 2 +-
 test/snapshot-expected/rollback/qemu-server/303.conf | 2 +-
 test/snapshot-input/commit/qemu-server/101.conf      | 2 +-
 test/snapshot-input/commit/qemu-server/102.conf      | 2 +-
 test/snapshot-input/commit/qemu-server/201.conf      | 2 +-
 test/snapshot-input/commit/qemu-server/202.conf      | 2 +-
 test/snapshot-input/commit/qemu-server/203.conf      | 2 +-
 test/snapshot-input/create/qemu-server/104.conf      | 2 +-
 test/snapshot-input/delete/qemu-server/101.conf      | 2 +-
 test/snapshot-input/delete/qemu-server/203.conf      | 2 +-
 test/snapshot-input/delete/qemu-server/204.conf      | 2 +-
 test/snapshot-input/rollback/qemu-server/101.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/102.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/103.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/104.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/106.conf    | 4 ++--
 test/snapshot-input/rollback/qemu-server/201.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/202.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/203.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/204.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/205.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/301.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/302.conf    | 2 +-
 test/snapshot-input/rollback/qemu-server/303.conf    | 2 +-
 test/snapshot-test.pm                                | 2 +-
 47 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/test/snapshot-expected/commit/qemu-server/101.conf b/test/snapshot-expected/commit/qemu-server/101.conf
index 060676e..82c9522 100644
--- a/test/snapshot-expected/commit/qemu-server/101.conf
+++ b/test/snapshot-expected/commit/qemu-server/101.conf
@@ -18,7 +18,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/commit/qemu-server/102.conf b/test/snapshot-expected/commit/qemu-server/102.conf
index 13f33a3..01b8531 100644
--- a/test/snapshot-expected/commit/qemu-server/102.conf
+++ b/test/snapshot-expected/commit/qemu-server/102.conf
@@ -34,7 +34,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/commit/qemu-server/201.conf b/test/snapshot-expected/commit/qemu-server/201.conf
index 63a6d77..f8e99dd 100644
--- a/test/snapshot-expected/commit/qemu-server/201.conf
+++ b/test/snapshot-expected/commit/qemu-server/201.conf
@@ -34,7 +34,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/commit/qemu-server/202.conf b/test/snapshot-expected/commit/qemu-server/202.conf
index 4c6b84d..a221ba0 100644
--- a/test/snapshot-expected/commit/qemu-server/202.conf
+++ b/test/snapshot-expected/commit/qemu-server/202.conf
@@ -35,7 +35,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/commit/qemu-server/203.conf b/test/snapshot-expected/commit/qemu-server/203.conf
index 5acf20d..e10b68e 100644
--- a/test/snapshot-expected/commit/qemu-server/203.conf
+++ b/test/snapshot-expected/commit/qemu-server/203.conf
@@ -35,7 +35,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/create/qemu-server/102.conf b/test/snapshot-expected/create/qemu-server/102.conf
index 9b57004..d507956 100644
--- a/test/snapshot-expected/create/qemu-server/102.conf
+++ b/test/snapshot-expected/create/qemu-server/102.conf
@@ -25,7 +25,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-expected/create/qemu-server/104.conf b/test/snapshot-expected/create/qemu-server/104.conf
index 54f1c21..385625f 100644
--- a/test/snapshot-expected/create/qemu-server/104.conf
+++ b/test/snapshot-expected/create/qemu-server/104.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
@@ -45,7 +45,7 @@ net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
 parent: test
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-expected/create/qemu-server/106.conf b/test/snapshot-expected/create/qemu-server/106.conf
index 9b57004..d507956 100644
--- a/test/snapshot-expected/create/qemu-server/106.conf
+++ b/test/snapshot-expected/create/qemu-server/106.conf
@@ -25,7 +25,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-expected/create/qemu-server/301.conf b/test/snapshot-expected/create/qemu-server/301.conf
index 9c49b1d..8cba2dc 100644
--- a/test/snapshot-expected/create/qemu-server/301.conf
+++ b/test/snapshot-expected/create/qemu-server/301.conf
@@ -25,7 +25,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-expected/create/qemu-server/302.conf b/test/snapshot-expected/create/qemu-server/302.conf
index 9c49b1d..8cba2dc 100644
--- a/test/snapshot-expected/create/qemu-server/302.conf
+++ b/test/snapshot-expected/create/qemu-server/302.conf
@@ -25,7 +25,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-expected/delete/qemu-server/203.conf b/test/snapshot-expected/delete/qemu-server/203.conf
index c406640..ed93cf7 100644
--- a/test/snapshot-expected/delete/qemu-server/203.conf
+++ b/test/snapshot-expected/delete/qemu-server/203.conf
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/delete/qemu-server/204.conf b/test/snapshot-expected/delete/qemu-server/204.conf
index c521154..fe63204 100644
--- a/test/snapshot-expected/delete/qemu-server/204.conf
+++ b/test/snapshot-expected/delete/qemu-server/204.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/prepare/qemu-server/102.conf b/test/snapshot-expected/prepare/qemu-server/102.conf
index 92db74a..8f998ca 100644
--- a/test/snapshot-expected/prepare/qemu-server/102.conf
+++ b/test/snapshot-expected/prepare/qemu-server/102.conf
@@ -23,7 +23,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snapstate: prepare
 snaptime: 1234567890
diff --git a/test/snapshot-expected/prepare/qemu-server/104.conf b/test/snapshot-expected/prepare/qemu-server/104.conf
index 02e2d3c..2f2ec96 100644
--- a/test/snapshot-expected/prepare/qemu-server/104.conf
+++ b/test/snapshot-expected/prepare/qemu-server/104.conf
@@ -41,7 +41,7 @@ net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
 parent: test
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snapstate: prepare
 snaptime: 1234567890
diff --git a/test/snapshot-expected/rollback/qemu-server/101.conf b/test/snapshot-expected/rollback/qemu-server/101.conf
index 91de880..17257e3 100644
--- a/test/snapshot-expected/rollback/qemu-server/101.conf
+++ b/test/snapshot-expected/rollback/qemu-server/101.conf
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/106.conf b/test/snapshot-expected/rollback/qemu-server/106.conf
index aa5fa9e..729bc93 100644
--- a/test/snapshot-expected/rollback/qemu-server/106.conf
+++ b/test/snapshot-expected/rollback/qemu-server/106.conf
@@ -3,7 +3,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/201.conf b/test/snapshot-expected/rollback/qemu-server/201.conf
index c521154..fe63204 100644
--- a/test/snapshot-expected/rollback/qemu-server/201.conf
+++ b/test/snapshot-expected/rollback/qemu-server/201.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/202.conf b/test/snapshot-expected/rollback/qemu-server/202.conf
index 691f5a2..d09b5d0 100644
--- a/test/snapshot-expected/rollback/qemu-server/202.conf
+++ b/test/snapshot-expected/rollback/qemu-server/202.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:unsnapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/203.conf b/test/snapshot-expected/rollback/qemu-server/203.conf
index 6e53b27..8abf841 100644
--- a/test/snapshot-expected/rollback/qemu-server/203.conf
+++ b/test/snapshot-expected/rollback/qemu-server/203.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/204.conf b/test/snapshot-expected/rollback/qemu-server/204.conf
index c406640..ed93cf7 100644
--- a/test/snapshot-expected/rollback/qemu-server/204.conf
+++ b/test/snapshot-expected/rollback/qemu-server/204.conf
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/205.conf b/test/snapshot-expected/rollback/qemu-server/205.conf
index c521154..fe63204 100644
--- a/test/snapshot-expected/rollback/qemu-server/205.conf
+++ b/test/snapshot-expected/rollback/qemu-server/205.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/301.conf b/test/snapshot-expected/rollback/qemu-server/301.conf
index c521154..fe63204 100644
--- a/test/snapshot-expected/rollback/qemu-server/301.conf
+++ b/test/snapshot-expected/rollback/qemu-server/301.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-expected/rollback/qemu-server/302.conf b/test/snapshot-expected/rollback/qemu-server/302.conf
index 828e8b0..5110016 100644
--- a/test/snapshot-expected/rollback/qemu-server/302.conf
+++ b/test/snapshot-expected/rollback/qemu-server/302.conf
@@ -27,7 +27,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-expected/rollback/qemu-server/303.conf b/test/snapshot-expected/rollback/qemu-server/303.conf
index 518c954..473a9a0 100644
--- a/test/snapshot-expected/rollback/qemu-server/303.conf
+++ b/test/snapshot-expected/rollback/qemu-server/303.conf
@@ -26,7 +26,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-input/commit/qemu-server/101.conf b/test/snapshot-input/commit/qemu-server/101.conf
index 4ab1787..92c1f6a 100644
--- a/test/snapshot-input/commit/qemu-server/101.conf
+++ b/test/snapshot-input/commit/qemu-server/101.conf
@@ -18,7 +18,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/commit/qemu-server/102.conf b/test/snapshot-input/commit/qemu-server/102.conf
index b62f2c6..99bca5e 100644
--- a/test/snapshot-input/commit/qemu-server/102.conf
+++ b/test/snapshot-input/commit/qemu-server/102.conf
@@ -35,7 +35,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/commit/qemu-server/201.conf b/test/snapshot-input/commit/qemu-server/201.conf
index 63a6d77..f8e99dd 100644
--- a/test/snapshot-input/commit/qemu-server/201.conf
+++ b/test/snapshot-input/commit/qemu-server/201.conf
@@ -34,7 +34,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/commit/qemu-server/202.conf b/test/snapshot-input/commit/qemu-server/202.conf
index 4c6b84d..a221ba0 100644
--- a/test/snapshot-input/commit/qemu-server/202.conf
+++ b/test/snapshot-input/commit/qemu-server/202.conf
@@ -35,7 +35,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/commit/qemu-server/203.conf b/test/snapshot-input/commit/qemu-server/203.conf
index 5acf20d..e10b68e 100644
--- a/test/snapshot-input/commit/qemu-server/203.conf
+++ b/test/snapshot-input/commit/qemu-server/203.conf
@@ -35,7 +35,7 @@ bootdisk: ide0
 cores: 4
 ide0: somestore:somedisk,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/create/qemu-server/104.conf b/test/snapshot-input/create/qemu-server/104.conf
index c521154..fe63204 100644
--- a/test/snapshot-input/create/qemu-server/104.conf
+++ b/test/snapshot-input/create/qemu-server/104.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/delete/qemu-server/101.conf b/test/snapshot-input/delete/qemu-server/101.conf
index c521154..fe63204 100644
--- a/test/snapshot-input/delete/qemu-server/101.conf
+++ b/test/snapshot-input/delete/qemu-server/101.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/delete/qemu-server/203.conf b/test/snapshot-input/delete/qemu-server/203.conf
index c406640..ed93cf7 100644
--- a/test/snapshot-input/delete/qemu-server/203.conf
+++ b/test/snapshot-input/delete/qemu-server/203.conf
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/delete/qemu-server/204.conf b/test/snapshot-input/delete/qemu-server/204.conf
index c521154..fe63204 100644
--- a/test/snapshot-input/delete/qemu-server/204.conf
+++ b/test/snapshot-input/delete/qemu-server/204.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/101.conf b/test/snapshot-input/rollback/qemu-server/101.conf
index 4fea865..0fa6a61 100644
--- a/test/snapshot-input/rollback/qemu-server/101.conf
+++ b/test/snapshot-input/rollback/qemu-server/101.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/102.conf b/test/snapshot-input/rollback/qemu-server/102.conf
index 8f0db83..3fcffe1 100644
--- a/test/snapshot-input/rollback/qemu-server/102.conf
+++ b/test/snapshot-input/rollback/qemu-server/102.conf
@@ -4,7 +4,7 @@ bootdisk: ide2
 cores: 2
 ide0: local:snapshotable-disk-1,size=32G
 ide2: none,media=cdrom
-machine: someothermachine
+machine: pc
 memory: 4096
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/103.conf b/test/snapshot-input/rollback/qemu-server/103.conf
index 8f0db83..3fcffe1 100644
--- a/test/snapshot-input/rollback/qemu-server/103.conf
+++ b/test/snapshot-input/rollback/qemu-server/103.conf
@@ -4,7 +4,7 @@ bootdisk: ide2
 cores: 2
 ide0: local:snapshotable-disk-1,size=32G
 ide2: none,media=cdrom
-machine: someothermachine
+machine: pc
 memory: 4096
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/104.conf b/test/snapshot-input/rollback/qemu-server/104.conf
index ff50151..2f12761 100644
--- a/test/snapshot-input/rollback/qemu-server/104.conf
+++ b/test/snapshot-input/rollback/qemu-server/104.conf
@@ -4,7 +4,7 @@ bootdisk: ide2
 cores: 2
 ide0: local:snapshotable-disk-1,size=32G
 ide2: none,media=cdrom
-machine: someothermachine
+machine: pc
 memory: 4096
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/106.conf b/test/snapshot-input/rollback/qemu-server/106.conf
index 64bf9bf..56d7199 100644
--- a/test/snapshot-input/rollback/qemu-server/106.conf
+++ b/test/snapshot-input/rollback/qemu-server/106.conf
@@ -3,7 +3,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: someothermachine
+machine: pc
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/201.conf b/test/snapshot-input/rollback/qemu-server/201.conf
index c521154..fe63204 100644
--- a/test/snapshot-input/rollback/qemu-server/201.conf
+++ b/test/snapshot-input/rollback/qemu-server/201.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/202.conf b/test/snapshot-input/rollback/qemu-server/202.conf
index 691f5a2..d09b5d0 100644
--- a/test/snapshot-input/rollback/qemu-server/202.conf
+++ b/test/snapshot-input/rollback/qemu-server/202.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:unsnapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/203.conf b/test/snapshot-input/rollback/qemu-server/203.conf
index 6e53b27..8abf841 100644
--- a/test/snapshot-input/rollback/qemu-server/203.conf
+++ b/test/snapshot-input/rollback/qemu-server/203.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/204.conf b/test/snapshot-input/rollback/qemu-server/204.conf
index c406640..ed93cf7 100644
--- a/test/snapshot-input/rollback/qemu-server/204.conf
+++ b/test/snapshot-input/rollback/qemu-server/204.conf
@@ -21,7 +21,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/205.conf b/test/snapshot-input/rollback/qemu-server/205.conf
index c521154..fe63204 100644
--- a/test/snapshot-input/rollback/qemu-server/205.conf
+++ b/test/snapshot-input/rollback/qemu-server/205.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/301.conf b/test/snapshot-input/rollback/qemu-server/301.conf
index c521154..fe63204 100644
--- a/test/snapshot-input/rollback/qemu-server/301.conf
+++ b/test/snapshot-input/rollback/qemu-server/301.conf
@@ -20,7 +20,7 @@ bootdisk: ide0
 cores: 4
 ide0: local:snapshotable-disk-1,discard=on,size=32G
 ide2: none,media=cdrom
-machine: somemachine
+machine: q35
 memory: 8192
 name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
diff --git a/test/snapshot-input/rollback/qemu-server/302.conf b/test/snapshot-input/rollback/qemu-server/302.conf
index 518c954..473a9a0 100644
--- a/test/snapshot-input/rollback/qemu-server/302.conf
+++ b/test/snapshot-input/rollback/qemu-server/302.conf
@@ -26,7 +26,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-input/rollback/qemu-server/303.conf b/test/snapshot-input/rollback/qemu-server/303.conf
index 518c954..473a9a0 100644
--- a/test/snapshot-input/rollback/qemu-server/303.conf
+++ b/test/snapshot-input/rollback/qemu-server/303.conf
@@ -26,7 +26,7 @@ name: win
 net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
 numa: 0
 ostype: win7
-runningmachine: somemachine
+runningmachine: q35
 smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
 snaptime: 1234567890
 sockets: 1
diff --git a/test/snapshot-test.pm b/test/snapshot-test.pm
index d26b422..5aca905 100644
--- a/test/snapshot-test.pm
+++ b/test/snapshot-test.pm
@@ -305,7 +305,7 @@ sub __snapshot_save_vmstate {
 
     my $snap = $conf->{snapshots}->{$snapname};
     $snap->{vmstate} = "somestorage:state-volume";
-    $snap->{runningmachine} = "somemachine"
+    $snap->{runningmachine} = "q35"
 }
 
 sub assert_config_exists_on_node {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH qemu-server v5 2/5] feature #3784: Parameter for guest vIOMMU & machine as property-string
  2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
@ 2023-01-18 13:57 ` Markus Frank
  2023-08-17 12:29   ` Fiona Ebner
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 3/5] added test-cases for new machine-syntax & viommu Markus Frank
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Markus Frank @ 2023-01-18 13:57 UTC (permalink / raw)
  To: pve-devel

vIOMMU enables the option to passthrough pci devices to L2 VMs
in L1 VMs via Nested Virtualisation.

QEMU-Parameters:
https://www.qemu.org/docs/master/system/qemu-manpage.html
https://wiki.qemu.org/Features/VT-d

-machine ...,kernel-irqchip=split:

"split" because of intremap see below.

-device intel-iommu:

* caching-mode=on:

"It is required for -device vfio-pci to work with the VT-d device, because host
assigned devices requires to setup the DMA mapping on the host before guest DMA
starts."

* intremap=on:

"This enables interrupt remapping feature. It's required to enable complete
x2apic. Currently it only supports kvm kernel-irqchip modes off or split, while
full kernel-irqchip is not yet supported."

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 PVE/API2/Qemu.pm          | 23 ++++++++++++++---
 PVE/QemuConfig.pm         |  3 ++-
 PVE/QemuServer.pm         | 52 ++++++++++++++++++++++++++++++++++++---
 PVE/QemuServer/Machine.pm |  6 +++--
 4 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c87602d..4e089f6 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -979,13 +979,21 @@ __PACKAGE__->register_method({
 			$conf->{vmgenid} = PVE::QemuServer::generate_uuid();
 		    }
 
-		    my $machine = $conf->{machine};
+		    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
+		    my $machine = $machine_conf->{type};
 		    if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
 			# always pin Windows' machine version on create, they get to easily confused
 			if (PVE::QemuServer::Helpers::windows_version($conf->{ostype})) {
-			    $conf->{machine} = PVE::QemuServer::windows_get_pinned_machine_version($machine);
+			    $machine_conf->{type} = PVE::QemuServer::windows_get_pinned_machine_version($machine);
+			    $conf->{machine} = PVE::QemuServer::print_machine($machine_conf);
 			}
 		    }
+		    my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
+		    my $kvm = $conf->{kvm};
+		    $kvm //= 1 if PVE::QemuServer::is_native($arch);
+		    if ($machine_conf->{viommu} && (!$kvm || !$q35)) {
+			die "to use vIOMMU please enable kvm and set the machine type to q35\n";
+		    }
 
 		    PVE::QemuConfig->write_config($vmid, $conf);
 
@@ -1770,7 +1778,16 @@ my $update_vm_api  = sub {
 		} elsif ($opt eq 'tags') {
 		    assert_tag_permissions($vmid, $conf->{$opt}, $param->{$opt}, $rpcenv, $authuser);
 		    $conf->{pending}->{$opt} = PVE::GuestHelpers::get_unique_tags($param->{$opt});
-		} else {
+		} elsif ($opt eq 'machine') {
+		    my $machine_conf = PVE::QemuServer::parse_machine($param->{$opt});
+		    my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
+		    my $kvm = $conf->{kvm};
+		    $kvm //= 1 if PVE::QemuServer::is_native($arch);
+		    if ($machine_conf->{viommu} && (!$kvm || !$q35)) {
+			die "to use vIOMMU please enable kvm and set the machine type to q35\n";
+		    }
+		    $conf->{pending}->{$opt} = $param->{$opt};
+		}else {
 		    $conf->{pending}->{$opt} = $param->{$opt};
 
 		    if ($opt eq 'boot') {
diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index 051382c..7c998ef 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -433,7 +433,8 @@ sub __snapshot_rollback_hook {
 	} else {
 	    # Note: old code did not store 'machine', so we try to be smart
 	    # and guess the snapshot was generated with kvm 1.4 (pc-i440fx-1.4).
-	    $data->{forcemachine} = $conf->{machine} || 'pc-i440fx-1.4';
+	    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
+	    $data->{forcemachine} = $machine_conf->{type} || 'pc-i440fx-1.4';
 
 	    # we remove the 'machine' configuration if not explicitly specified
 	    # in the original config.
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 987908d..55c11d5 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -124,6 +124,19 @@ PVE::JSONSchema::register_standard_option('pve-qemu-machine', {
 	optional => 1,
 });
 
+my $machine_fmt = {
+    type => get_standard_option('pve-qemu-machine', {
+	default_key => 1,
+	format_description => "pve-qemu-machine-type",
+    }),
+    viommu => {
+	type => 'boolean',
+	description => "enable guest vIOMMU (needs kvm to be enabled and q35 to be set as machine)",
+	default => 0,
+	optional => 1,
+    },
+};
+
 # FIXME: remove in favor of just using the INotify one, it's cached there exactly the same way
 my $nodename_cache;
 sub nodename {
@@ -626,7 +639,12 @@ EODESCR
 	pattern => $PVE::QemuServer::CPUConfig::qemu_cmdline_cpu_re,
 	format_description => 'QEMU -cpu parameter'
     },
-    machine => get_standard_option('pve-qemu-machine'),
+    machine => {
+	description => "Specifies the Qemu machine type.",
+	type => 'string',
+	optional => 1,
+	format => $machine_fmt,
+    },
     arch => {
 	description => "Virtual processor architecture. Defaults to the host.",
 	optional => 1,
@@ -2134,6 +2152,21 @@ sub parse_watchdog {
     return $res;
 }
 
+sub parse_machine {
+    my ($value) = @_;
+
+    return if !$value;
+
+    my $res = eval { parse_property_string($machine_fmt, $value) };
+    die $@ if $@;
+    return $res;
+}
+
+sub print_machine {
+    my ($machine_conf) = @_;
+    return PVE::JSONSchema::print_property_string($machine_conf, $machine_fmt);
+}
+
 sub parse_guest_agent {
     my ($conf) = @_;
 
@@ -2205,8 +2238,9 @@ sub qemu_created_version_fixups {
     # check if we need to apply some handling for VMs that always use the latest machine version but
     # had a machine version transition happen that affected HW such that, e.g., an OS config change
     # would be required (we do not want to pin machine version for non-windows OS type)
+    my $machine_conf = parse_machine($conf->{machine});
     if (
-	(!defined($conf->{machine}) || $conf->{machine} =~ m/^(?:pc|q35|virt)$/) # non-versioned machine
+	(!defined($machine_conf->{type}) || $machine_conf->{type} =~ m/^(?:pc|q35|virt)$/) # non-versioned machine
 	&& (!defined($meta->{'creation-qemu'}) || !min_version($meta->{'creation-qemu'}, 6, 1)) # created before 6.1
 	&& (!$forced_vers || min_version($forced_vers, 6, 1)) # handle snapshot-rollback/migrations
 	&& min_version($kvmver, 6, 1) # only need to apply the change since 6.1
@@ -3335,7 +3369,8 @@ sub windows_get_pinned_machine_version {
 sub get_vm_machine {
     my ($conf, $forcemachine, $arch, $add_pve_version, $kvmversion) = @_;
 
-    my $machine = $forcemachine || $conf->{machine};
+    my $machine_conf = parse_machine($conf->{machine});
+    my $machine = $forcemachine || $machine_conf->{type};
 
     if (!$machine || $machine =~ m/^(?:pc|q35|virt)$/) {
 	$kvmversion //= kvm_user_version();
@@ -3575,6 +3610,8 @@ sub config_to_command {
     my $kvm = $conf->{kvm};
     my $nodename = nodename();
 
+    my $machine_conf = parse_machine($conf->{machine});
+
     my $arch = get_vm_arch($conf);
     my $kvm_binary = get_command_for_arch($arch);
     my $kvmver = kvm_user_version($kvm_binary);
@@ -4137,6 +4174,15 @@ sub config_to_command {
     }
     push @$machineFlags, "type=${machine_type_min}";
 
+    if ($machine_conf->{viommu} && (!$kvm || !$q35)) {
+        die "to use vIOMMU please enable kvm and set the machine type to q35\n";
+    }
+
+    if ($machine_conf->{viommu}) {
+	unshift @$devices, '-device', "intel-iommu,intremap=on,caching-mode=on";
+	push @$machineFlags, 'kernel-irqchip=split';
+    }
+
     push @$cmd, @$devices;
     push @$cmd, '-rtc', join(',', @$rtcFlags) if scalar(@$rtcFlags);
     push @$cmd, '-machine', join(',', @$machineFlags) if scalar(@$machineFlags);
diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
index d9429ed..bfbde59 100644
--- a/PVE/QemuServer/Machine.pm
+++ b/PVE/QemuServer/Machine.pm
@@ -15,7 +15,8 @@ our $PVE_MACHINE_VERSION = {
 sub machine_type_is_q35 {
     my ($conf) = @_;
 
-    return $conf->{machine} && ($conf->{machine} =~ m/q35/) ? 1 : 0;
+    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
+    return $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
 }
 
 sub current_from_query_machines {
@@ -120,7 +121,8 @@ sub qemu_machine_pxe {
 
     my $machine =  get_current_qemu_machine($vmid);
 
-    if ($conf->{machine} && $conf->{machine} =~ m/\.pxe$/) {
+    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
+    if ($machine_conf->{type} && $machine_conf->{type} =~ m/\.pxe$/) {
 	$machine .= '.pxe';
     }
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH qemu-server v5 3/5] added test-cases for new machine-syntax & viommu
  2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 2/5] feature #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
@ 2023-01-18 13:57 ` Markus Frank
  2023-01-18 13:57 ` [pve-devel] [PATCH docs v5 4/5] added vIOMMU documentation Markus Frank
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Markus Frank @ 2023-01-18 13:57 UTC (permalink / raw)
  To: pve-devel

added two test-cases to test the new machine parameter with viommu

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 test/cfg2cmd/q35-viommu-alt.conf     |  1 +
 test/cfg2cmd/q35-viommu-alt.conf.cmd | 23 +++++++++++++++++++++++
 test/cfg2cmd/q35-viommu.conf         |  1 +
 test/cfg2cmd/q35-viommu.conf.cmd     | 23 +++++++++++++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 test/cfg2cmd/q35-viommu-alt.conf
 create mode 100644 test/cfg2cmd/q35-viommu-alt.conf.cmd
 create mode 100644 test/cfg2cmd/q35-viommu.conf
 create mode 100644 test/cfg2cmd/q35-viommu.conf.cmd

diff --git a/test/cfg2cmd/q35-viommu-alt.conf b/test/cfg2cmd/q35-viommu-alt.conf
new file mode 100644
index 0000000..44d38e2
--- /dev/null
+++ b/test/cfg2cmd/q35-viommu-alt.conf
@@ -0,0 +1 @@
+machine: q35,viommu=1
diff --git a/test/cfg2cmd/q35-viommu-alt.conf.cmd b/test/cfg2cmd/q35-viommu-alt.conf.cmd
new file mode 100644
index 0000000..24e873d
--- /dev/null
+++ b/test/cfg2cmd/q35-viommu-alt.conf.cmd
@@ -0,0 +1,23 @@
+/usr/bin/kvm \
+  -id 8006 \
+  -name 'vm8006,debug-threads=on' \
+  -no-shutdown \
+  -chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
+  -mon 'chardev=qmp,mode=control' \
+  -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' \
+  -mon 'chardev=qmp-event,mode=control' \
+  -pidfile /var/run/qemu-server/8006.pid \
+  -daemonize \
+  -smp '1,sockets=1,cores=1,maxcpus=1' \
+  -nodefaults \
+  -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \
+  -m 512 \
+  -device 'intel-iommu,intremap=on,caching-mode=on' \
+  -readconfig /usr/share/qemu-server/pve-q35-4.0.cfg \
+  -device 'usb-tablet,id=tablet,bus=ehci.0,port=1' \
+  -device 'VGA,id=vga,bus=pcie.0,addr=0x1' \
+  -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
+  -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
+  -machine 'type=q35+pve0,kernel-irqchip=split'
diff --git a/test/cfg2cmd/q35-viommu.conf b/test/cfg2cmd/q35-viommu.conf
new file mode 100644
index 0000000..6925a74
--- /dev/null
+++ b/test/cfg2cmd/q35-viommu.conf
@@ -0,0 +1 @@
+machine: type=q35,viommu=1
diff --git a/test/cfg2cmd/q35-viommu.conf.cmd b/test/cfg2cmd/q35-viommu.conf.cmd
new file mode 100644
index 0000000..24e873d
--- /dev/null
+++ b/test/cfg2cmd/q35-viommu.conf.cmd
@@ -0,0 +1,23 @@
+/usr/bin/kvm \
+  -id 8006 \
+  -name 'vm8006,debug-threads=on' \
+  -no-shutdown \
+  -chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
+  -mon 'chardev=qmp,mode=control' \
+  -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect=5' \
+  -mon 'chardev=qmp-event,mode=control' \
+  -pidfile /var/run/qemu-server/8006.pid \
+  -daemonize \
+  -smp '1,sockets=1,cores=1,maxcpus=1' \
+  -nodefaults \
+  -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \
+  -m 512 \
+  -device 'intel-iommu,intremap=on,caching-mode=on' \
+  -readconfig /usr/share/qemu-server/pve-q35-4.0.cfg \
+  -device 'usb-tablet,id=tablet,bus=ehci.0,port=1' \
+  -device 'VGA,id=vga,bus=pcie.0,addr=0x1' \
+  -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
+  -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
+  -machine 'type=q35+pve0,kernel-irqchip=split'
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH docs v5 4/5] added vIOMMU documentation
  2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
                   ` (2 preceding siblings ...)
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 3/5] added test-cases for new machine-syntax & viommu Markus Frank
@ 2023-01-18 13:57 ` Markus Frank
  2023-08-17 12:41   ` Fiona Ebner
  2023-01-18 13:58 ` [pve-devel] [PATCH manager v5 5/5] ui: MachineEdit with viommu checkbox Markus Frank
  2023-06-19 10:32 ` [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
  5 siblings, 1 reply; 11+ messages in thread
From: Markus Frank @ 2023-01-18 13:57 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 qm-pci-passthrough.adoc | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/qm-pci-passthrough.adoc b/qm-pci-passthrough.adoc
index df6cf21..0db9b06 100644
--- a/qm-pci-passthrough.adoc
+++ b/qm-pci-passthrough.adoc
@@ -400,6 +400,31 @@ Example configuration with an `Intel GVT-g vGPU` (`Intel Skylake 6700k`):
 With this set, {pve} automatically creates such a device on VM start, and
 cleans it up again when the VM stops.
 
+[[qm_pci_viommu]]
+vIOMMU
+~~~~~~
+
+vIOMMU enables the option to passthrough pci devices to Level-2 VMs
+in Level-1 VMs via Nested Virtualisation.
+
+Host Requirement: Add `intel_iommu=on` or `amd_iommu=on`
+depending on your CPU to your kernel command line.
+
+VM Requirement: For both Intel and AMD CPUs, set `intel_iommu=on`
+as the kernel parameter in the vIOMMU enabled VM, since qemu-server currently
+uses the Intel variant. The guest vIOMMU only works with the *q35* machine
+type and with *kvm* enabled.
+
+To enable vIOMMU, add `viommu=1` to the machine-parameter in the
+configuration of the VM that should be able to passthrough pci devices.
+
+----
+# qm set VMID -machine q35,viommu=1
+----
+
+
+https://wiki.qemu.org/Features/VT-d
+
 ifdef::wiki[]
 
 See Also
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] [PATCH manager v5 5/5] ui: MachineEdit with viommu checkbox
  2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
                   ` (3 preceding siblings ...)
  2023-01-18 13:57 ` [pve-devel] [PATCH docs v5 4/5] added vIOMMU documentation Markus Frank
@ 2023-01-18 13:58 ` Markus Frank
  2023-08-17 13:59   ` Fiona Ebner
  2023-06-19 10:32 ` [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
  5 siblings, 1 reply; 11+ messages in thread
From: Markus Frank @ 2023-01-18 13:58 UTC (permalink / raw)
  To: pve-devel

Added a checkbox to enable viommu, if q35 is selected.
Otherwise (i440fx & !kvm) the checkbox is disabled, if not ticked on
before. If ticked on before, the user is able to uncheck the checkbox.

If kvm is deactivated or i440fx is selected, a hint tells that q35 and
kvm are required for vIOMMU.

The UI also needs to parse the new machine parameter as PropertyString.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 www/manager6/qemu/MachineEdit.js | 58 ++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
index f928c80c..d7650ea9 100644
--- a/www/manager6/qemu/MachineEdit.js
+++ b/www/manager6/qemu/MachineEdit.js
@@ -1,6 +1,7 @@
 Ext.define('PVE.qemu.MachineInputPanel', {
     extend: 'Proxmox.panel.InputPanel',
     xtype: 'pveMachineInputPanel',
+    onlineHelp: 'qm_pci_viommu',
 
     controller: {
 	xclass: 'Ext.app.ViewController',
@@ -12,11 +13,26 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 	onMachineChange: function(field, value) {
 	    let me = this;
 	    let version = me.lookup('version');
+	    let kvm = me.lookup('kvm');
+	    let viommu = me.lookup('viommu');
+	    let kvmHint = me.lookup('kvmQ35Hint');
 	    let store = version.getStore();
 	    let oldRec = store.findRecord('id', version.getValue(), 0, false, false, true);
 	    let type = value === 'q35' ? 'q35' : 'i440fx';
 	    store.clearFilter();
 	    store.addFilter(val => val.data.id === 'latest' || val.data.type === type);
+	    if ((type === 'q35' && kvm.getValue()) || viommu.getValue()) {
+		viommu.setDisabled(false);
+		kvmHint.setVisible(false);
+	    } else {
+		// disable checkbox if vIOMMU is not possible and checkbox was not
+		// ticked on before
+		viommu.setDisabled(true);
+	    }
+	    if (type === 'i440fx' || !kvm.getValue()) {
+		// show hint when vIOMMU cannot be used
+		kvmHint.setVisible(true);
+	    }
 	    if (!me.getView().isWindows) {
 		version.setValue('latest');
 	    } else {
@@ -38,14 +54,27 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 	if (values.version && values.version !== 'latest') {
 	    values.machine = values.version;
 	    delete values.delete;
+	} else if (values.machine === undefined && values.viommu) {
+	    // set machine to pc to raise the viommu + i440fx error
+	    // from qemu-server instead of a regex error
+	    values.machine = "pc";
+	    delete values.delete;
 	}
 	delete values.version;
+	if (values.viommu) {
+	    values.machine += ",viommu=1";
+	}
+	delete values.viommu;
+	delete values.kvm;
 	return values;
     },
 
     setValues: function(values) {
 	let me = this;
 
+	let machineConf = PVE.Parser.parsePropertyString(values.machine, "type");
+	values.machine = machineConf.type;
+
 	me.isWindows = values.isWindows;
 	if (values.machine === 'pc') {
 	    values.machine = '__default__';
@@ -58,6 +87,11 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 		values.version = 'pc-q35-5.1';
 	    }
 	}
+
+	me.lookup('kvm').setValue(values.kvm);
+	values.viommu = machineConf.viommu === '1';
+	me.lookup('viommu').setValue(values.viommu);
+
 	if (values.machine !== '__default__' && values.machine !== 'q35') {
 	    values.version = values.machine;
 	    values.machine = values.version.match(/q35/) ? 'q35' : '__default__';
@@ -113,6 +147,26 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 	    fieldLabel: gettext('Note'),
 	    value: gettext('Machine version change may affect hardware layout and settings in the guest OS.'),
 	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('vIOMMU'),
+	    name: 'viommu',
+	    reference: 'viommu',
+	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    name: 'kvm',
+	    reference: 'kvm',
+	    hidden: true,
+	},
+	{
+	    xtype: 'displayfield',
+	    name: 'kvmQ35Hint',
+	    reference: 'kvmQ35Hint',
+	    userCls: 'pmx-hint',
+	    value: gettext('vIOMMU needs kvm enabled and q35 firmware'),
+	    hidden: true,
+	},
     ],
 });
 
@@ -135,8 +189,12 @@ Ext.define('PVE.qemu.MachineEdit', {
 	me.load({
 	    success: function(response) {
 		let conf = response.result.data;
+		if (conf.kvm === undefined || conf.kvm === null) {
+		    conf.kvm = 1;
+		}
 		let values = {
 		    machine: conf.machine || '__default__',
+		    kvm: conf.kvm,
 		};
 		values.isWindows = PVE.Utils.is_windows(conf.ostype);
 		me.setValues(values);
-- 
2.30.2





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature
  2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
                   ` (4 preceding siblings ...)
  2023-01-18 13:58 ` [pve-devel] [PATCH manager v5 5/5] ui: MachineEdit with viommu checkbox Markus Frank
@ 2023-06-19 10:32 ` Markus Frank
  5 siblings, 0 replies; 11+ messages in thread
From: Markus Frank @ 2023-06-19 10:32 UTC (permalink / raw)
  To: pve-devel

ping

On 1/18/23 14:57, Markus Frank wrote:
> qemu-server:
> 
> v5:
> * set $kvm to 1 if is_native, so that api kvm check works.
> 
> v4:
> * added kvm/q35 checks in API
> * reused pve-qemu-machine
> 
> v3:
> * replaced old machine type with property-string with viommu-parameter
> 
> v2:
> * moved viommu-parameter inside of machine_fmt and added it the new
> parameter machine_properties
> new Config -> machine_properties: viommu=1,etc
> * check if kvm and q35 are set
> 
> 
> Markus Frank (3):
>    tests: replaced somemachine&someothermachine with q35&pc
>    fix #3784: Parameter for guest vIOMMU & machine as property-string
>    added test-cases for new machine-syntax & viommu
> 
>   PVE/API2/Qemu.pm                              | 23 ++++++--
>   PVE/QemuConfig.pm                             |  3 +-
>   PVE/QemuServer.pm                             | 52 +++++++++++++++++--
>   PVE/QemuServer/Machine.pm                     |  6 ++-
>   test/cfg2cmd/q35-viommu-alt.conf              |  1 +
>   test/cfg2cmd/q35-viommu-alt.conf.cmd          | 23 ++++++++
>   test/cfg2cmd/q35-viommu.conf                  |  1 +
>   test/cfg2cmd/q35-viommu.conf.cmd              | 23 ++++++++
>   .../commit/qemu-server/101.conf               |  2 +-
>   .../commit/qemu-server/102.conf               |  2 +-
>   .../commit/qemu-server/201.conf               |  2 +-
>   .../commit/qemu-server/202.conf               |  2 +-
>   .../commit/qemu-server/203.conf               |  2 +-
>   .../create/qemu-server/102.conf               |  2 +-
>   .../create/qemu-server/104.conf               |  4 +-
>   .../create/qemu-server/106.conf               |  2 +-
>   .../create/qemu-server/301.conf               |  2 +-
>   .../create/qemu-server/302.conf               |  2 +-
>   .../delete/qemu-server/203.conf               |  2 +-
>   .../delete/qemu-server/204.conf               |  2 +-
>   .../prepare/qemu-server/102.conf              |  2 +-
>   .../prepare/qemu-server/104.conf              |  2 +-
>   .../rollback/qemu-server/101.conf             |  2 +-
>   .../rollback/qemu-server/106.conf             |  4 +-
>   .../rollback/qemu-server/201.conf             |  2 +-
>   .../rollback/qemu-server/202.conf             |  2 +-
>   .../rollback/qemu-server/203.conf             |  2 +-
>   .../rollback/qemu-server/204.conf             |  2 +-
>   .../rollback/qemu-server/205.conf             |  2 +-
>   .../rollback/qemu-server/301.conf             |  2 +-
>   .../rollback/qemu-server/302.conf             |  2 +-
>   .../rollback/qemu-server/303.conf             |  2 +-
>   .../commit/qemu-server/101.conf               |  2 +-
>   .../commit/qemu-server/102.conf               |  2 +-
>   .../commit/qemu-server/201.conf               |  2 +-
>   .../commit/qemu-server/202.conf               |  2 +-
>   .../commit/qemu-server/203.conf               |  2 +-
>   .../create/qemu-server/104.conf               |  2 +-
>   .../delete/qemu-server/101.conf               |  2 +-
>   .../delete/qemu-server/203.conf               |  2 +-
>   .../delete/qemu-server/204.conf               |  2 +-
>   .../rollback/qemu-server/101.conf             |  2 +-
>   .../rollback/qemu-server/102.conf             |  2 +-
>   .../rollback/qemu-server/103.conf             |  2 +-
>   .../rollback/qemu-server/104.conf             |  2 +-
>   .../rollback/qemu-server/106.conf             |  4 +-
>   .../rollback/qemu-server/201.conf             |  2 +-
>   .../rollback/qemu-server/202.conf             |  2 +-
>   .../rollback/qemu-server/203.conf             |  2 +-
>   .../rollback/qemu-server/204.conf             |  2 +-
>   .../rollback/qemu-server/205.conf             |  2 +-
>   .../rollback/qemu-server/301.conf             |  2 +-
>   .../rollback/qemu-server/302.conf             |  2 +-
>   .../rollback/qemu-server/303.conf             |  2 +-
>   test/snapshot-test.pm                         |  2 +-
>   55 files changed, 173 insertions(+), 59 deletions(-)
>   create mode 100644 test/cfg2cmd/q35-viommu-alt.conf
>   create mode 100644 test/cfg2cmd/q35-viommu-alt.conf.cmd
>   create mode 100644 test/cfg2cmd/q35-viommu.conf
>   create mode 100644 test/cfg2cmd/q35-viommu.conf.cmd
> 
> 
> docs:
> 
> v5:
> * changed Host and VM Requirements
> 
> Markus Frank (1):
>    added vIOMMU documentation
> 
>   qm-pci-passthrough.adoc | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> 
> manager:
> 
> v5:
> * added check if kvm is undefined or null
> 
> v4:
> * check if kvm is enabled
> * added kvm+q35 hint
> 
> Markus Frank (1):
>    ui: MachineEdit with viommu checkbox
> 
>   www/manager6/qemu/MachineEdit.js | 58 ++++++++++++++++++++++++++++++++
>   1 file changed, 58 insertions(+)
> 




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [pve-devel] applied: [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
@ 2023-08-17 11:43   ` Fiona Ebner
  0 siblings, 0 replies; 11+ messages in thread
From: Fiona Ebner @ 2023-08-17 11:43 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

Am 18.01.23 um 14:57 schrieb Markus Frank:
> needed for new machine parameter
> 
> parse_property_string checks for the regex, therefore the test-cases
> with somemachine & someothermachine always fail.
> 
> So I changed somemachine & someothermachine to q35 & pc with sed
> 
> sed -i 's/somemachine/q35/g'
> sed -i 's/someothermachine/pc/g'
> 
> Signed-off-by: Markus Frank <m.frank@proxmox.com>

applied, thanks! Changed the commit message and title a bit, to
(hopefully) make it slightly more readable.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [pve-devel] [PATCH qemu-server v5 2/5] feature #3784: Parameter for guest vIOMMU & machine as property-string
  2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 2/5] feature #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
@ 2023-08-17 12:29   ` Fiona Ebner
  0 siblings, 0 replies; 11+ messages in thread
From: Fiona Ebner @ 2023-08-17 12:29 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

Am 18.01.23 um 14:57 schrieb Markus Frank:
> vIOMMU enables the option to passthrough pci devices to L2 VMs
> in L1 VMs via Nested Virtualisation.
> 
> QEMU-Parameters:
> https://www.qemu.org/docs/master/system/qemu-manpage.html
> https://wiki.qemu.org/Features/VT-d
> 
> -machine ...,kernel-irqchip=split:
> 
> "split" because of intremap see below.
> 
> -device intel-iommu:
> 
> * caching-mode=on:
> 
> "It is required for -device vfio-pci to work with the VT-d device, because host
> assigned devices requires to setup the DMA mapping on the host before guest DMA
> starts."
> 
> * intremap=on:
> 
> "This enables interrupt remapping feature. It's required to enable complete
> x2apic. Currently it only supports kvm kernel-irqchip modes off or split, while
> full kernel-irqchip is not yet supported."
> 
> Signed-off-by: Markus Frank <m.frank@proxmox.com>
> ---

This one needs a rebase

(...)

> +		    my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
> +		    my $kvm = $conf->{kvm};
> +		    $kvm //= 1 if PVE::QemuServer::is_native($arch);
> +		    if ($machine_conf->{viommu} && (!$kvm || !$q35)) {
> +			die "to use vIOMMU please enable kvm and set the machine type to q35\n";
> +		    }
>  
>  		    PVE::QemuConfig->write_config($vmid, $conf);
>  
> @@ -1770,7 +1778,16 @@ my $update_vm_api  = sub {
>  		} elsif ($opt eq 'tags') {
>  		    assert_tag_permissions($vmid, $conf->{$opt}, $param->{$opt}, $rpcenv, $authuser);
>  		    $conf->{pending}->{$opt} = PVE::GuestHelpers::get_unique_tags($param->{$opt});
> -		} else {
> +		} elsif ($opt eq 'machine') {
> +		    my $machine_conf = PVE::QemuServer::parse_machine($param->{$opt});
> +		    my $q35 = $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
> +		    my $kvm = $conf->{kvm};
> +		    $kvm //= 1 if PVE::QemuServer::is_native($arch);
> +		    if ($machine_conf->{viommu} && (!$kvm || !$q35)) {
> +			die "to use vIOMMU please enable kvm and set the machine type to q35\n";
> +		    }

Maybe worth adding a helper function taking in the config and the
machine option. It's the very same check as above.

> +		    $conf->{pending}->{$opt} = $param->{$opt};
> +		}else {

Style nit: missing space before else

>  		    $conf->{pending}->{$opt} = $param->{$opt};
>  
>  		    if ($opt eq 'boot') {
> diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
> index 051382c..7c998ef 100644
> --- a/PVE/QemuConfig.pm
> +++ b/PVE/QemuConfig.pm
> @@ -433,7 +433,8 @@ sub __snapshot_rollback_hook {
>  	} else {
>  	    # Note: old code did not store 'machine', so we try to be smart
>  	    # and guess the snapshot was generated with kvm 1.4 (pc-i440fx-1.4).
> -	    $data->{forcemachine} = $conf->{machine} || 'pc-i440fx-1.4';
> +	    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
> +	    $data->{forcemachine} = $machine_conf->{type} || 'pc-i440fx-1.4';
>  
>  	    # we remove the 'machine' configuration if not explicitly specified
>  	    # in the original config.
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 987908d..55c11d5 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -124,6 +124,19 @@ PVE::JSONSchema::register_standard_option('pve-qemu-machine', {
>  	optional => 1,
>  });
>  
> +my $machine_fmt = {
> +    type => get_standard_option('pve-qemu-machine', {

Any reason against changing the standard option itself to be the whole
property string rather than keep the option just being the type? I
noticed that 'runningmachine' still uses only
"get_standard_option('pve-qemu-machine'", but that is wrong after this
patch. Changing the standard option itself would avoid that.

> +	default_key => 1,
> +	format_description => "pve-qemu-machine-type",

That format description is not very telling at all. Usually, this is
used to clarify what exact format the string is, e.g. base64. I don't
think it's needed here and there's already a description of the property
itself.

> +    }),
> +    viommu => {
> +	type => 'boolean',
> +	description => "enable guest vIOMMU (needs kvm to be enabled and q35 to be set as machine)",

Nit: "as machine type" sounds slightly better now that machine is more
than just the type

> +	default => 0,
> +	optional => 1,
> +    },
> +};
> +
>  # FIXME: remove in favor of just using the INotify one, it's cached there exactly the same way
>  my $nodename_cache;
>  sub nodename {
> @@ -626,7 +639,12 @@ EODESCR
>  	pattern => $PVE::QemuServer::CPUConfig::qemu_cmdline_cpu_re,
>  	format_description => 'QEMU -cpu parameter'
>      },
> -    machine => get_standard_option('pve-qemu-machine'),
> +    machine => {
> +	description => "Specifies the Qemu machine type.",

Nit: QEMU should be capitalized

> +	type => 'string',
> +	optional => 1,
> +	format => $machine_fmt,
> +    },
>      arch => {
>  	description => "Virtual processor architecture. Defaults to the host.",
>  	optional => 1,
> @@ -2134,6 +2152,21 @@ sub parse_watchdog {
>      return $res;
>  }
>  
> +sub parse_machine {
> +    my ($value) = @_;
> +
> +    return if !$value;
> +
> +    my $res = eval { parse_property_string($machine_fmt, $value) };
> +    die $@ if $@;

No need for eval if you just die with the exact same error ;)

> +    return $res;
> +}
> +
> +sub print_machine {
> +    my ($machine_conf) = @_;
> +    return PVE::JSONSchema::print_property_string($machine_conf, $machine_fmt);
> +}
> +
>  sub parse_guest_agent {
>      my ($conf) = @_;
>  

(...)

> @@ -4137,6 +4174,15 @@ sub config_to_command {
>      }
>      push @$machineFlags, "type=${machine_type_min}";
>  
> +    if ($machine_conf->{viommu} && (!$kvm || !$q35)) {
> +        die "to use vIOMMU please enable kvm and set the machine type to q35\n";
> +    }
> +
> +    if ($machine_conf->{viommu}) {

Style nit: the check for kvm+q35 and the die from above could be moved
into this block

Or instead re-use the check helper I suggested above

> +	unshift @$devices, '-device', "intel-iommu,intremap=on,caching-mode=on";
> +	push @$machineFlags, 'kernel-irqchip=split';
> +    }
> +
>      push @$cmd, @$devices;
>      push @$cmd, '-rtc', join(',', @$rtcFlags) if scalar(@$rtcFlags);
>      push @$cmd, '-machine', join(',', @$machineFlags) if scalar(@$machineFlags);
> diff --git a/PVE/QemuServer/Machine.pm b/PVE/QemuServer/Machine.pm
> index d9429ed..bfbde59 100644
> --- a/PVE/QemuServer/Machine.pm
> +++ b/PVE/QemuServer/Machine.pm
> @@ -15,7 +15,8 @@ our $PVE_MACHINE_VERSION = {
>  sub machine_type_is_q35 {
>      my ($conf) = @_;
>  
> -    return $conf->{machine} && ($conf->{machine} =~ m/q35/) ? 1 : 0;
> +    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
> +    return $machine_conf->{type} && ($machine_conf->{type} =~ m/q35/) ? 1 : 0;
>  }

The parse and print functions and option definition should really live
inside here, i.e. Machine.pm. The Machine module should not call back
into PVE::QemuServer if we can somehow avoid it.

>  
>  sub current_from_query_machines {
> @@ -120,7 +121,8 @@ sub qemu_machine_pxe {
>  
>      my $machine =  get_current_qemu_machine($vmid);
>  
> -    if ($conf->{machine} && $conf->{machine} =~ m/\.pxe$/) {
> +    my $machine_conf = PVE::QemuServer::parse_machine($conf->{machine});
> +    if ($machine_conf->{type} && $machine_conf->{type} =~ m/\.pxe$/) {
>  	$machine .= '.pxe';
>      }
>  




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [pve-devel] [PATCH docs v5 4/5] added vIOMMU documentation
  2023-01-18 13:57 ` [pve-devel] [PATCH docs v5 4/5] added vIOMMU documentation Markus Frank
@ 2023-08-17 12:41   ` Fiona Ebner
  0 siblings, 0 replies; 11+ messages in thread
From: Fiona Ebner @ 2023-08-17 12:41 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

Am 18.01.23 um 14:57 schrieb Markus Frank:
> Signed-off-by: Markus Frank <m.frank@proxmox.com>
> ---
>  qm-pci-passthrough.adoc | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/qm-pci-passthrough.adoc b/qm-pci-passthrough.adoc
> index df6cf21..0db9b06 100644
> --- a/qm-pci-passthrough.adoc
> +++ b/qm-pci-passthrough.adoc
> @@ -400,6 +400,31 @@ Example configuration with an `Intel GVT-g vGPU` (`Intel Skylake 6700k`):
>  With this set, {pve} automatically creates such a device on VM start, and
>  cleans it up again when the VM stops.
>  
> +[[qm_pci_viommu]]
> +vIOMMU
> +~~~~~~
> +
> +vIOMMU enables the option to passthrough pci devices to Level-2 VMs
> +in Level-1 VMs via Nested Virtualisation.

Nit: "PCI" should be capitalized, "level" and "nested virtualization" not.

Instead of "vIOMMU enables the option to" maybe "Using a vIOMMU allows
you to" or "With a vIOMMU you can" are slightly better IMHO.

> +> +Host Requirement: Add `intel_iommu=on` or `amd_iommu=on`
> +depending on your CPU to your kernel command line.

Nit: capitalization of "Requirement" here. You could argue it's a title,
but not sure.

> +
> +VM Requirement: For both Intel and AMD CPUs, set `intel_iommu=on`
> +as the kernel parameter in the vIOMMU enabled VM, since qemu-server currently
> +uses the Intel variant. The guest vIOMMU only works with the *q35* machine
> +type and with *kvm* enabled.

A quick sentence why we use the Intel variant might be good

> +
> +To enable vIOMMU, add `viommu=1` to the machine-parameter in the
> +configuration of the VM that should be able to passthrough pci devices.

Nit: "PCI"

> +
> +----
> +# qm set VMID -machine q35,viommu=1
> +----
> +
> +
> +https://wiki.qemu.org/Features/VT-d
> +
>  ifdef::wiki[]
>  
>  See Also




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [pve-devel] [PATCH manager v5 5/5] ui: MachineEdit with viommu checkbox
  2023-01-18 13:58 ` [pve-devel] [PATCH manager v5 5/5] ui: MachineEdit with viommu checkbox Markus Frank
@ 2023-08-17 13:59   ` Fiona Ebner
  0 siblings, 0 replies; 11+ messages in thread
From: Fiona Ebner @ 2023-08-17 13:59 UTC (permalink / raw)
  To: Proxmox VE development discussion, Markus Frank

Am 18.01.23 um 14:58 schrieb Markus Frank:
> @@ -38,14 +54,27 @@ Ext.define('PVE.qemu.MachineInputPanel', {
>  	if (values.version && values.version !== 'latest') {
>  	    values.machine = values.version;
>  	    delete values.delete;
> +	} else if (values.machine === undefined && values.viommu) {
> +	    // set machine to pc to raise the viommu + i440fx error
> +	    // from qemu-server instead of a regex error
> +	    values.machine = "pc";
> +	    delete values.delete;
>  	}
>  	delete values.version;
> +	if (values.viommu) {
> +	    values.machine += ",viommu=1";
> +	}

Nit: could use PVE.Parser.printPropertyString but no big deal

> +	delete values.viommu;
> +	delete values.kvm;
>  	return values;
>      },
>  
>      setValues: function(values) {
>  	let me = this;
>  
> +	let machineConf = PVE.Parser.parsePropertyString(values.machine, "type");
> +	values.machine = machineConf.type;
> +
>  	me.isWindows = values.isWindows;
>  	if (values.machine === 'pc') {
>  	    values.machine = '__default__';
> @@ -58,6 +87,11 @@ Ext.define('PVE.qemu.MachineInputPanel', {
>  		values.version = 'pc-q35-5.1';
>  	    }
>  	}
> +
> +	me.lookup('kvm').setValue(values.kvm);
> +	values.viommu = machineConf.viommu === '1';

Should be PVE.Parser.parseBoolean to cover all cases (i.e. also 'on',
'yes' and 'true' can be in the config)

> +	me.lookup('viommu').setValue(values.viommu);
> +
>  	if (values.machine !== '__default__' && values.machine !== 'q35') {
>  	    values.version = values.machine;
>  	    values.machine = values.version.match(/q35/) ? 'q35' : '__default__';
> @@ -113,6 +147,26 @@ Ext.define('PVE.qemu.MachineInputPanel', {
>  	    fieldLabel: gettext('Note'),
>  	    value: gettext('Machine version change may affect hardware layout and settings in the guest OS.'),
>  	},
> +	{
> +	    xtype: 'proxmoxcheckbox',
> +	    fieldLabel: gettext('vIOMMU'),
> +	    name: 'viommu',
> +	    reference: 'viommu',
> +	},
> +	{
> +	    xtype: 'proxmoxcheckbox',
> +	    name: 'kvm',
> +	    reference: 'kvm',
> +	    hidden: true,
> +	},

Why handle 'kvm' as an UI element? I guess a view model property would
be the natural place for this.

> +	{
> +	    xtype: 'displayfield',
> +	    name: 'kvmQ35Hint',
> +	    reference: 'kvmQ35Hint',
> +	    userCls: 'pmx-hint',
> +	    value: gettext('vIOMMU needs kvm enabled and q35 firmware'),

s/firmware/machine type/

> +	    hidden: true,
> +	},
>      ],
>  });
>  
> @@ -135,8 +189,12 @@ Ext.define('PVE.qemu.MachineEdit', {
>  	me.load({
>  	    success: function(response) {
>  		let conf = response.result.data;
> +		if (conf.kvm === undefined || conf.kvm === null) {
> +		    conf.kvm = 1;
> +		}

Style nit: could be one line with conf.kvm ??= 1;

>  		let values = {
>  		    machine: conf.machine || '__default__',
> +		    kvm: conf.kvm,
>  		};
>  		values.isWindows = PVE.Utils.is_windows(conf.ostype);
>  		me.setValues(values);




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-08-17 13:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 13:57 [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank
2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
2023-08-17 11:43   ` [pve-devel] applied: " Fiona Ebner
2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 2/5] feature #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
2023-08-17 12:29   ` Fiona Ebner
2023-01-18 13:57 ` [pve-devel] [PATCH qemu-server v5 3/5] added test-cases for new machine-syntax & viommu Markus Frank
2023-01-18 13:57 ` [pve-devel] [PATCH docs v5 4/5] added vIOMMU documentation Markus Frank
2023-08-17 12:41   ` Fiona Ebner
2023-01-18 13:58 ` [pve-devel] [PATCH manager v5 5/5] ui: MachineEdit with viommu checkbox Markus Frank
2023-08-17 13:59   ` Fiona Ebner
2023-06-19 10:32 ` [pve-devel] [PATCH qemu-server/manager/docs v5 0/5] vIOMMU-Feature Markus Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal