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

qemu-server:
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                              | 21 +++++--
 PVE/QemuConfig.pm                             |  3 +-
 PVE/QemuServer.pm                             | 55 ++++++++++++++++++-
 PVE/QemuServer/Machine.pm                     |  6 +-
 test/cfg2cmd/viommu.conf                      |  1 +
 test/cfg2cmd/viommu.conf.cmd                  | 23 ++++++++
 test/restore-config-expected/401.conf         | 14 +++++
 test/restore-config-expected/402.conf         | 14 +++++
 test/restore-config-input/401.conf            | 14 +++++
 test/restore-config-input/402.conf            | 14 +++++
 test/run_qemu_restore_config_tests.pl         |  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/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 +-
 .../create/qemu-server/401.conf               | 32 +++++++++++
 .../create/qemu-server/402.conf               | 53 ++++++++++++++++++
 .../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 +-
 .../create/qemu-server/401.conf               | 14 +++++
 .../create/qemu-server/402.conf               | 33 +++++++++++
 .../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                         |  8 ++-
 62 files changed, 344 insertions(+), 61 deletions(-)
 create mode 100644 test/cfg2cmd/viommu.conf
 create mode 100644 test/cfg2cmd/viommu.conf.cmd
 create mode 100644 test/restore-config-expected/401.conf
 create mode 100644 test/restore-config-expected/402.conf
 create mode 100644 test/restore-config-input/401.conf
 create mode 100644 test/restore-config-input/402.conf
 create mode 100644 test/snapshot-expected/create/qemu-server/401.conf
 create mode 100644 test/snapshot-expected/create/qemu-server/402.conf
 create mode 100644 test/snapshot-input/create/qemu-server/401.conf
 create mode 100644 test/snapshot-input/create/qemu-server/402.conf


docs:

Markus Frank (1):
  added vIOMMU documentation

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


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

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

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



-- 
2.30.2





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

* [pve-devel] [PATCH qemu-server v4 1/5] tests: replaced somemachine&someothermachine with q35&pc
  2022-11-25 14:08 [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
@ 2022-11-25 14:08 ` Markus Frank
  2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 2/5] fix #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Markus Frank @ 2022-11-25 14:08 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 3f1ac7c..50c5857 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] 13+ messages in thread

* [pve-devel] [PATCH qemu-server v4 2/5] fix #3784: Parameter for guest vIOMMU & machine as property-string
  2022-11-25 14:08 [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
  2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
@ 2022-11-25 14:08 ` Markus Frank
  2023-01-13  9:51   ` Wolfgang Bumiller
  2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 3/5] added test-cases for new machine-syntax & viommu Markus Frank
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Markus Frank @ 2022-11-25 14:08 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>
---

for dmar on virtio-devices:

* device-iotlb

"This enables device-iotlb capability for the emulated VT-d device. So far
virtio/vhost should be the only real user for this parameter, paired with
ats=on configured for the device."

* disable-legacy=on,disable-modern=off,iommu_platform=on,ats=on:

I did not find any good documentation.
Maybe someone can explain these parameters and how to use them right.
As I tried them with virtio-net-pci I got about 4-9 times less transfer-speed
when sending then without them.

However these Parameters seem not to be necessary for passthroughing
Assigned Devices, so I would say "dmar for virtio" would be its own
separate feature.

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


 PVE/API2/Qemu.pm          | 21 ++++++++++++---
 PVE/QemuConfig.pm         |  3 ++-
 PVE/QemuServer.pm         | 55 ++++++++++++++++++++++++++++++++++++---
 PVE/QemuServer/Machine.pm |  6 +++--
 4 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index badfc37..5268e56 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -979,13 +979,19 @@ __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);
+			if (PVE::QemuServer::windows_version($conf->{ostype})) {
+			    $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;
+		    if ((!$conf->{kvm} || !$q35) && $machine_conf->{viommu}) {
+			die "to use vIOMMU please enable kvm and set the machine type to q35\n"
+		    }
 
 		    PVE::QemuConfig->write_config($vmid, $conf);
 
@@ -1770,7 +1776,14 @@ 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;
+		    if ((!$conf->{kvm} || !$q35) && $machine_conf->{viommu}) {
+			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 a746b3d..05eb757 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -123,6 +123,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 {
@@ -625,7 +638,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,
@@ -2128,6 +2146,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) = @_;
 
@@ -2199,8 +2232,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
@@ -3327,7 +3361,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();
@@ -3526,6 +3561,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);
@@ -3579,6 +3616,14 @@ sub config_to_command {
     my $use_old_bios_files = undef;
     ($use_old_bios_files, $machine_type) = qemu_use_old_bios_files($machine_type);
 
+    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}) {
+	push @$devices, '-device', "intel-iommu,intremap=on,caching-mode=on";
+    }
+
     my $cmd = [];
     if ($conf->{affinity}) {
 	push @$cmd, '/usr/bin/taskset', '--cpu-list', '--all-tasks', $conf->{affinity};
@@ -4132,6 +4177,10 @@ sub config_to_command {
     }
     push @$machineFlags, "type=${machine_type_min}";
 
+    if ($machine_conf->{viommu}) {
+	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] 13+ messages in thread

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

added a few test-cases to test the new machine parameter with viommu

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
 test/cfg2cmd/viommu.conf                      |  1 +
 test/cfg2cmd/viommu.conf.cmd                  | 23 ++++++++
 test/restore-config-expected/401.conf         | 14 +++++
 test/restore-config-expected/402.conf         | 14 +++++
 test/restore-config-input/401.conf            | 14 +++++
 test/restore-config-input/402.conf            | 14 +++++
 test/run_qemu_restore_config_tests.pl         |  2 +-
 .../create/qemu-server/401.conf               | 32 +++++++++++
 .../create/qemu-server/402.conf               | 53 +++++++++++++++++++
 .../create/qemu-server/401.conf               | 14 +++++
 .../create/qemu-server/402.conf               | 33 ++++++++++++
 test/snapshot-test.pm                         |  6 +++
 12 files changed, 219 insertions(+), 1 deletion(-)
 create mode 100644 test/cfg2cmd/viommu.conf
 create mode 100644 test/cfg2cmd/viommu.conf.cmd
 create mode 100644 test/restore-config-expected/401.conf
 create mode 100644 test/restore-config-expected/402.conf
 create mode 100644 test/restore-config-input/401.conf
 create mode 100644 test/restore-config-input/402.conf
 create mode 100644 test/snapshot-expected/create/qemu-server/401.conf
 create mode 100644 test/snapshot-expected/create/qemu-server/402.conf
 create mode 100644 test/snapshot-input/create/qemu-server/401.conf
 create mode 100644 test/snapshot-input/create/qemu-server/402.conf

diff --git a/test/cfg2cmd/viommu.conf b/test/cfg2cmd/viommu.conf
new file mode 100644
index 0000000..6925a74
--- /dev/null
+++ b/test/cfg2cmd/viommu.conf
@@ -0,0 +1 @@
+machine: type=q35,viommu=1
diff --git a/test/cfg2cmd/viommu.conf.cmd b/test/cfg2cmd/viommu.conf.cmd
new file mode 100644
index 0000000..24e873d
--- /dev/null
+++ b/test/cfg2cmd/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'
diff --git a/test/restore-config-expected/401.conf b/test/restore-config-expected/401.conf
new file mode 100644
index 0000000..9400351
--- /dev/null
+++ b/test/restore-config-expected/401.conf
@@ -0,0 +1,14 @@
+bootdisk: scsi0
+cores: 1
+ide2: none,media=cdrom
+memory: 512
+machine: q35,viommu=1
+name: apache
+net0: virtio=92:38:11:FD:ED:87,bridge=vmbr0,firewall=1
+numa: 0
+ostype: l26
+scsi0: target:401/vm-401-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+vmgenid: 0
diff --git a/test/restore-config-expected/402.conf b/test/restore-config-expected/402.conf
new file mode 100644
index 0000000..73f69cb
--- /dev/null
+++ b/test/restore-config-expected/402.conf
@@ -0,0 +1,14 @@
+bootdisk: scsi0
+cores: 1
+ide2: none,media=cdrom
+memory: 512
+machine: type=q35,viommu=1
+name: apache
+net0: virtio=92:38:11:FD:ED:87,bridge=vmbr0,firewall=1
+numa: 0
+ostype: l26
+scsi0: target:401/vm-402-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+vmgenid: 0
diff --git a/test/restore-config-input/401.conf b/test/restore-config-input/401.conf
new file mode 100644
index 0000000..9400351
--- /dev/null
+++ b/test/restore-config-input/401.conf
@@ -0,0 +1,14 @@
+bootdisk: scsi0
+cores: 1
+ide2: none,media=cdrom
+memory: 512
+machine: q35,viommu=1
+name: apache
+net0: virtio=92:38:11:FD:ED:87,bridge=vmbr0,firewall=1
+numa: 0
+ostype: l26
+scsi0: target:401/vm-401-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+vmgenid: 0
diff --git a/test/restore-config-input/402.conf b/test/restore-config-input/402.conf
new file mode 100644
index 0000000..73f69cb
--- /dev/null
+++ b/test/restore-config-input/402.conf
@@ -0,0 +1,14 @@
+bootdisk: scsi0
+cores: 1
+ide2: none,media=cdrom
+memory: 512
+machine: type=q35,viommu=1
+name: apache
+net0: virtio=92:38:11:FD:ED:87,bridge=vmbr0,firewall=1
+numa: 0
+ostype: l26
+scsi0: target:401/vm-402-disk-0.qcow2,size=4G
+scsihw: virtio-scsi-pci
+smbios1: uuid=ddf91b3f-a597-42be-9a7e-fb6421dcd5cd
+sockets: 1
+vmgenid: 0
diff --git a/test/run_qemu_restore_config_tests.pl b/test/run_qemu_restore_config_tests.pl
index 1e1e807..2221abe 100755
--- a/test/run_qemu_restore_config_tests.pl
+++ b/test/run_qemu_restore_config_tests.pl
@@ -25,7 +25,7 @@ $pve_cluster_module->mock(
 );
 
 # NOTE update when you add/remove tests
-plan tests => 4;
+plan tests => 6;
 
 my $cfs_mock = Test::MockModule->new("PVE::Cluster");
 $cfs_mock->mock(
diff --git a/test/snapshot-expected/create/qemu-server/401.conf b/test/snapshot-expected/create/qemu-server/401.conf
new file mode 100644
index 0000000..56cb71c
--- /dev/null
+++ b/test/snapshot-expected/create/qemu-server/401.conf
@@ -0,0 +1,32 @@
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+machine: q35,viommu=1
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+parent: test
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+sockets: 1
+vga: qxl
+
+[test]
+#test comment
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+machine: q35,viommu=1
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+parent: test
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+snaptime: 1234567890
+sockets: 1
+vga: qxl
diff --git a/test/snapshot-expected/create/qemu-server/402.conf b/test/snapshot-expected/create/qemu-server/402.conf
new file mode 100644
index 0000000..ac485ce
--- /dev/null
+++ b/test/snapshot-expected/create/qemu-server/402.conf
@@ -0,0 +1,53 @@
+agent: 1
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+parent: test2
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+sockets: 1
+vga: qxl
+
+[test]
+#test comment
+agent: 1
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+machine: q35,viommu=1
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+snaptime: 1234567890
+sockets: 1
+vga: qxl
+vmstate: somestorage:state-volume
+
+[test2]
+#test comment
+agent: 1
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+parent: test
+runningmachine: q35
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+snaptime: 1234567890
+sockets: 1
+vga: qxl
+vmstate: somestorage:state-volume
diff --git a/test/snapshot-input/create/qemu-server/401.conf b/test/snapshot-input/create/qemu-server/401.conf
new file mode 100644
index 0000000..8feec27
--- /dev/null
+++ b/test/snapshot-input/create/qemu-server/401.conf
@@ -0,0 +1,14 @@
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+machine: q35,viommu=1
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+parent: test
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+sockets: 1
+vga: qxl
diff --git a/test/snapshot-input/create/qemu-server/402.conf b/test/snapshot-input/create/qemu-server/402.conf
new file mode 100644
index 0000000..72f89ce
--- /dev/null
+++ b/test/snapshot-input/create/qemu-server/402.conf
@@ -0,0 +1,33 @@
+agent: 1
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+parent: test
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+sockets: 1
+vga: qxl
+
+[test]
+#test comment
+agent: 1
+bootdisk: ide0
+cores: 4
+ide0: local:snapshotable-disk-1,discard=on,size=32G
+ide2: none,media=cdrom
+machine: q35,viommu=1
+memory: 8192
+name: win
+net0: e1000=12:34:56:78:90:12,bridge=somebr0,firewall=1
+numa: 0
+ostype: win7
+smbios1: uuid=01234567-890a-bcde-f012-34567890abcd
+snaptime: 1234567890
+sockets: 1
+vga: qxl
+vmstate: somestorage:state-volume
diff --git a/test/snapshot-test.pm b/test/snapshot-test.pm
index 50c5857..3fcb0eb 100644
--- a/test/snapshot-test.pm
+++ b/test/snapshot-test.pm
@@ -566,6 +566,12 @@ $vm_mon->{savevm_start} = 1;
 printf("Successful snapshot_create with no existing snapshots but set machine type\n");
 testcase_create("301", "test", 1, "test comment", "", { "local:snapshotable-disk-1" => "test" });
 
+printf("Successful snapshot_create with viommu enabled\n");
+testcase_create("401", "test", 0, "test comment", "", { "local:snapshotable-disk-1" => "test" });
+
+printf("Successful snapshot_create with viommu enabled and with one existing snapshots including vmstate\n");
+testcase_create("402", "test2", 1, "test comment", "", { "local:snapshotable-disk-1" => "test2" });
+
 $activate_storage_possible = 0;
 
 printf("Expected error for snapshot_create when storage activation is not possible\n");
-- 
2.30.2





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

* [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation
  2022-11-25 14:08 [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
                   ` (2 preceding siblings ...)
  2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 3/5] added test-cases for new machine-syntax & viommu Markus Frank
@ 2022-11-25 14:08 ` Markus Frank
  2023-01-13 10:09   ` Wolfgang Bumiller
  2022-11-25 14:08 ` [pve-devel] [PATCH manager v4 5/5] ui: MachineEdit with viommu checkbox Markus Frank
  2023-01-12 13:51 ` [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
  5 siblings, 1 reply; 13+ messages in thread
From: Markus Frank @ 2022-11-25 14:08 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 fa6ba35..7ed4d49 100644
--- a/qm-pci-passthrough.adoc
+++ b/qm-pci-passthrough.adoc
@@ -389,6 +389,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: Set `intel_iommu=on` or `amd_iommu=on` depending on your
+CPU.
+
+VM-Requirement: For both Intel and AMD CPUs you will have to set
+`intel_iommu=on` as a Linux boot parameter in the vIOMMU-enabled-VM, because
+Qemu implements the Intel variant.
+
+To enable vIOMMU you have to add `viommu=1` to the machine-parameter in the
+VM-Configuration, of the VM that you want to be able to passthrough pci devices.
+
+----
+# qm set VMID -machine q35,viommu=1
+----
+
+Guest vIOMMU only works with the *q35* machine type and with *kvm* enabled.
+
+https://wiki.qemu.org/Features/VT-d
+
 ifdef::wiki[]
 
 See Also
-- 
2.30.2





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

* [pve-devel] [PATCH manager v4 5/5] ui: MachineEdit with viommu checkbox
  2022-11-25 14:08 [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
                   ` (3 preceding siblings ...)
  2022-11-25 14:08 ` [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation Markus Frank
@ 2022-11-25 14:08 ` Markus Frank
  2023-01-12 13:51 ` [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
  5 siblings, 0 replies; 13+ messages in thread
From: Markus Frank @ 2022-11-25 14:08 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 | 56 ++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
index f928c80c..03fcf36d 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 {
@@ -35,17 +51,31 @@ Ext.define('PVE.qemu.MachineInputPanel', {
     },
 
     onGetValues: function(values) {
+	console.log(values);
 	if (values.version && values.version !== 'latest') {
 	    values.machine = values.version;
 	    delete values.delete;
+	} else if ((typeof values.machine === 'undefined') && values.viommu) {
+	    // set machine to pc to raise the viommu + i440fx error from backend
+	    // instead of 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 +88,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 +148,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,
+	},
     ],
 });
 
@@ -137,6 +192,7 @@ Ext.define('PVE.qemu.MachineEdit', {
 		let conf = response.result.data;
 		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] 13+ messages in thread

* Re: [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature
  2022-11-25 14:08 [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
                   ` (4 preceding siblings ...)
  2022-11-25 14:08 ` [pve-devel] [PATCH manager v4 5/5] ui: MachineEdit with viommu checkbox Markus Frank
@ 2023-01-12 13:51 ` Markus Frank
  5 siblings, 0 replies; 13+ messages in thread
From: Markus Frank @ 2023-01-12 13:51 UTC (permalink / raw)
  To: Proxmox VE development discussion

Ping, because of demand from users.

On 11/25/22 15:08, Markus Frank wrote:
> qemu-server:
> 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                              | 21 +++++--
>   PVE/QemuConfig.pm                             |  3 +-
>   PVE/QemuServer.pm                             | 55 ++++++++++++++++++-
>   PVE/QemuServer/Machine.pm                     |  6 +-
>   test/cfg2cmd/viommu.conf                      |  1 +
>   test/cfg2cmd/viommu.conf.cmd                  | 23 ++++++++
>   test/restore-config-expected/401.conf         | 14 +++++
>   test/restore-config-expected/402.conf         | 14 +++++
>   test/restore-config-input/401.conf            | 14 +++++
>   test/restore-config-input/402.conf            | 14 +++++
>   test/run_qemu_restore_config_tests.pl         |  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/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 +-
>   .../create/qemu-server/401.conf               | 32 +++++++++++
>   .../create/qemu-server/402.conf               | 53 ++++++++++++++++++
>   .../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 +-
>   .../create/qemu-server/401.conf               | 14 +++++
>   .../create/qemu-server/402.conf               | 33 +++++++++++
>   .../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                         |  8 ++-
>   62 files changed, 344 insertions(+), 61 deletions(-)
>   create mode 100644 test/cfg2cmd/viommu.conf
>   create mode 100644 test/cfg2cmd/viommu.conf.cmd
>   create mode 100644 test/restore-config-expected/401.conf
>   create mode 100644 test/restore-config-expected/402.conf
>   create mode 100644 test/restore-config-input/401.conf
>   create mode 100644 test/restore-config-input/402.conf
>   create mode 100644 test/snapshot-expected/create/qemu-server/401.conf
>   create mode 100644 test/snapshot-expected/create/qemu-server/402.conf
>   create mode 100644 test/snapshot-input/create/qemu-server/401.conf
>   create mode 100644 test/snapshot-input/create/qemu-server/402.conf
> 
> 
> docs:
> 
> Markus Frank (1):
>    added vIOMMU documentation
> 
>   qm-pci-passthrough.adoc | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> 
> manager:
> v4:
> * check if kvm is enabled
> * added kvm+q35 hint
> 
> Markus Frank (1):
>    ui: MachineEdit with viommu checkbox
> 
>   www/manager6/qemu/MachineEdit.js | 56 ++++++++++++++++++++++++++++++++
>   1 file changed, 56 insertions(+)
> 
> 
> 




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

* Re: [pve-devel] [PATCH qemu-server v4 2/5] fix #3784: Parameter for guest vIOMMU & machine as property-string
  2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 2/5] fix #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
@ 2023-01-13  9:51   ` Wolfgang Bumiller
  0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Bumiller @ 2023-01-13  9:51 UTC (permalink / raw)
  To: Markus Frank; +Cc: pve-devel

On Fri, Nov 25, 2022 at 03:08:54PM +0100, Markus Frank wrote:
> 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:

AFAICT qemu also has an amd-iommu - so shouldn't we check the host arch
for which variant we need to use?

> 
> * 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>
> ---
> 
> for dmar on virtio-devices:
> 
> * device-iotlb
> 
> "This enables device-iotlb capability for the emulated VT-d device. So far
> virtio/vhost should be the only real user for this parameter, paired with
> ats=on configured for the device."
> 
> * disable-legacy=on,disable-modern=off,iommu_platform=on,ats=on:
> 
> I did not find any good documentation.
> Maybe someone can explain these parameters and how to use them right.
> As I tried them with virtio-net-pci I got about 4-9 times less transfer-speed
> when sending then without them.

I mean, the viommu adds overhead, so I'd expect some downsides.

- iommu_platform=on:
Now, normally virtio devices can just directly access the guest memory
since the hypervisor has full access. `iommu_platform=on` disables this,
and it'll go through some generic DMA process that is supposed to deal
with things such as AMD-SEV where the hypervisor doesn't actually have
access to the full guest memory. I'd expect a large performance hit from
that.

I don't expect the others to make much of a difference, in fact, AFAICT
disable-legacy shouldn't do much at all on modern guests I think.

- 'disable-legacy=on':
Virtio has evolved quite a bit and this option AFAICT disables support
for "legacy" (pre-virtio-1.0) parts, but I don't know the details, you
can probably read them in the virtio spec, it mentions things such as
pci configuration space having been in native-endian rather than
little-endian as is defined by PCI (apparently).

There are apparently 3 "flavors" of virtio devices: legacy,
transitional (supporting "IO" and "MMIO" modes (according to qemu's
docs/pcie.txt)), and modern. Qemu seems to decide the defaults there
depending on whether the device is on a pci or pcie port.
disable-legacy and disable-modern override this explicitly.

> 
> However these Parameters seem not to be necessary for passthroughing
> Assigned Devices, so I would say "dmar for virtio" would be its own
> separate feature.
> 
> 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
> 
> 
>  PVE/API2/Qemu.pm          | 21 ++++++++++++---
>  PVE/QemuConfig.pm         |  3 ++-
>  PVE/QemuServer.pm         | 55 ++++++++++++++++++++++++++++++++++++---
>  PVE/QemuServer/Machine.pm |  6 +++--
>  4 files changed, 75 insertions(+), 10 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index badfc37..5268e56 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -979,13 +979,19 @@ __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);
> +			if (PVE::QemuServer::windows_version($conf->{ostype})) {

You dropped the Helpers::' part here, is this intentional? AFAICT
"windows_version still lives in Helpers.pm?

> +			    $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;
> +		    if ((!$conf->{kvm} || !$q35) && $machine_conf->{viommu}) {
> +			die "to use vIOMMU please enable kvm and set the machine type to q35\n"
> +		    }
>  
>  		    PVE::QemuConfig->write_config($vmid, $conf);
>  




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

* Re: [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation
  2022-11-25 14:08 ` [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation Markus Frank
@ 2023-01-13 10:09   ` Wolfgang Bumiller
  2023-01-13 13:31     ` Markus Frank
  0 siblings, 1 reply; 13+ messages in thread
From: Wolfgang Bumiller @ 2023-01-13 10:09 UTC (permalink / raw)
  To: Markus Frank; +Cc: pve-devel

On Fri, Nov 25, 2022 at 03:08:56PM +0100, Markus Frank wrote:
> 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 fa6ba35..7ed4d49 100644
> --- a/qm-pci-passthrough.adoc
> +++ b/qm-pci-passthrough.adoc
> @@ -389,6 +389,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: Set `intel_iommu=on` or `amd_iommu=on` depending on your
> +CPU.

And by "CPU" you mean kernel command line? ;-)

> +
> +VM-Requirement: For both Intel and AMD CPUs you will have to set
> +`intel_iommu=on` as a Linux boot parameter in the vIOMMU-enabled-VM, because
> +Qemu implements the Intel variant.

^ As mentioned, there does appear to be an amd_iommu device in the qemu
code, so would the amd variant work?

In my reply to the code patch I mentioned checking the host arch. But if
you say we can use intel_iommu on AMD as well, I'd say, if both work,
give the user a choice, otherwise we can of course just stick to the one
that works ;-)




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

* Re: [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation
  2023-01-13 10:09   ` Wolfgang Bumiller
@ 2023-01-13 13:31     ` Markus Frank
  2023-01-16 10:00       ` Wolfgang Bumiller
  0 siblings, 1 reply; 13+ messages in thread
From: Markus Frank @ 2023-01-13 13:31 UTC (permalink / raw)
  To: Wolfgang Bumiller; +Cc: Proxmox VE development discussion



On 1/13/23 11:09, Wolfgang Bumiller wrote:
> On Fri, Nov 25, 2022 at 03:08:56PM +0100, Markus Frank wrote:
>> 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 fa6ba35..7ed4d49 100644
>> --- a/qm-pci-passthrough.adoc
>> +++ b/qm-pci-passthrough.adoc
>> @@ -389,6 +389,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: Set `intel_iommu=on` or `amd_iommu=on` depending on your
>> +CPU.
> 
> And by "CPU" you mean kernel command line? ;-)

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

like this?
> 
>> +
>> +VM-Requirement: For both Intel and AMD CPUs you will have to set
>> +`intel_iommu=on` as a Linux boot parameter in the vIOMMU-enabled-VM, because
>> +Qemu implements the Intel variant.
> 
> ^ As mentioned, there does appear to be an amd_iommu device in the qemu
> code, so would the amd variant work?
> 
> In my reply to the code patch I mentioned checking the host arch. But if
> you say we can use intel_iommu on AMD as well, I'd say, if both work,
> give the user a choice, otherwise we can of course just stick to the one
> that works ;-)

intel_iommu works better on my AMD CPU than amd_iommu ;)
Moreover it adds an extra AMDVI-PCI device that is using the first pci address.
`kvm: -device VGA,id=vga,bus=pcie.0,addr=0x1: PCI: slot 1 function 0 not available for VGA, in use by AMDVI-PCI,id=(null)`

I cannot find any good documentation for amd_iommu but it also seems like
it has less features.

$ qemu-system-x86_64 -device 'amd-iommu,help'
amd-iommu options:
   device-iotlb=<bool>    -  (default: false)
   intremap=<OnOffAuto>   - on/off/auto (default: "auto")
   pt=<bool>              -  (default: true)
$ qemu-system-x86_64 -device 'intel-iommu,help'
intel-iommu options:
   aw-bits=<uint8>        -  (default: 39)
   caching-mode=<bool>    -  (default: false)
   device-iotlb=<bool>    -  (default: false)
   dma-drain=<bool>       -  (default: true)
   dma-translation=<bool> -  (default: true)
   eim=<OnOffAuto>        - on/off/auto (default: "auto")
   intremap=<OnOffAuto>   - on/off/auto (default: "auto")
   pt=<bool>              -  (default: true)
   snoop-control=<bool>   -  (default: false)
   version=<uint32>       -  (default: 0)
   x-buggy-eim=<bool>     -  (default: false)
   x-pasid-mode=<bool>    -  (default: false)
   x-scalable-mode=<bool> -  (default: false)




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

* Re: [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation
  2023-01-13 13:31     ` Markus Frank
@ 2023-01-16 10:00       ` Wolfgang Bumiller
  2023-01-17 10:55         ` Markus Frank
  0 siblings, 1 reply; 13+ messages in thread
From: Wolfgang Bumiller @ 2023-01-16 10:00 UTC (permalink / raw)
  To: Markus Frank; +Cc: Proxmox VE development discussion

On Fri, Jan 13, 2023 at 02:31:36PM +0100, Markus Frank wrote:
> 
> 
> On 1/13/23 11:09, Wolfgang Bumiller wrote:
> > On Fri, Nov 25, 2022 at 03:08:56PM +0100, Markus Frank wrote:
> > > 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 fa6ba35..7ed4d49 100644
> > > --- a/qm-pci-passthrough.adoc
> > > +++ b/qm-pci-passthrough.adoc
> > > @@ -389,6 +389,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: Set `intel_iommu=on` or `amd_iommu=on` depending on your
> > > +CPU.
> > 
> > And by "CPU" you mean kernel command line? ;-)
> 
> Host-Requirement: Add `intel_iommu=on` or `amd_iommu=on`
> depending on your CPU to your kernel command line.
> 
> like this?
> > 
> > > +
> > > +VM-Requirement: For both Intel and AMD CPUs you will have to set
> > > +`intel_iommu=on` as a Linux boot parameter in the vIOMMU-enabled-VM, because
> > > +Qemu implements the Intel variant.
> > 
> > ^ As mentioned, there does appear to be an amd_iommu device in the qemu
> > code, so would the amd variant work?
> > 
> > In my reply to the code patch I mentioned checking the host arch. But if
> > you say we can use intel_iommu on AMD as well, I'd say, if both work,
> > give the user a choice, otherwise we can of course just stick to the one
> > that works ;-)
> 
> intel_iommu works better on my AMD CPU than amd_iommu ;)

Can you define "better"?
My main concern is that if we don't give users the option to choose, the
only data point we have is yours ;-)
If we explicitly mention that you can use one on the other in the docs,
people can try it themselves and maybe we'll see some feedback on the
forums etc.

However, I'm fine with a patch for only the intel version for now as we
can always add an option later.

> Moreover it adds an extra AMDVI-PCI device that is using the first pci address.
> `kvm: -device VGA,id=vga,bus=pcie.0,addr=0x1: PCI: slot 1 function 0 not available for VGA, in use by AMDVI-PCI,id=(null)`

For that I'd say, try to add the AMDVI-PCI device manually to an
explicitly chosen slot. We need to avoid automatically added devices
like the plague, because moving them later can break live snapshots (and
windows).

> 
> I cannot find any good documentation for amd_iommu but it also seems like
> it has less features.

Less, or just not configurable? ;-)
I mean, if it works it works ;-)

> 
> $ qemu-system-x86_64 -device 'amd-iommu,help'
> amd-iommu options:
>   device-iotlb=<bool>    -  (default: false)
>   intremap=<OnOffAuto>   - on/off/auto (default: "auto")
>   pt=<bool>              -  (default: true)
> $ qemu-system-x86_64 -device 'intel-iommu,help'
> intel-iommu options:
>   aw-bits=<uint8>        -  (default: 39)
>   caching-mode=<bool>    -  (default: false)
>   device-iotlb=<bool>    -  (default: false)
>   dma-drain=<bool>       -  (default: true)
>   dma-translation=<bool> -  (default: true)
>   eim=<OnOffAuto>        - on/off/auto (default: "auto")
>   intremap=<OnOffAuto>   - on/off/auto (default: "auto")
>   pt=<bool>              -  (default: true)
>   snoop-control=<bool>   -  (default: false)
>   version=<uint32>       -  (default: 0)
>   x-buggy-eim=<bool>     -  (default: false)
>   x-pasid-mode=<bool>    -  (default: false)
>   x-scalable-mode=<bool> -  (default: false)




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

* Re: [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation
  2023-01-16 10:00       ` Wolfgang Bumiller
@ 2023-01-17 10:55         ` Markus Frank
  2023-01-17 15:01           ` Wolfgang Bumiller
  0 siblings, 1 reply; 13+ messages in thread
From: Markus Frank @ 2023-01-17 10:55 UTC (permalink / raw)
  To: Wolfgang Bumiller; +Cc: Proxmox VE development discussion



On 1/16/23 11:00, Wolfgang Bumiller wrote:
> On Fri, Jan 13, 2023 at 02:31:36PM +0100, Markus Frank wrote:
>>
>>
>> On 1/13/23 11:09, Wolfgang Bumiller wrote:
>>> On Fri, Nov 25, 2022 at 03:08:56PM +0100, Markus Frank wrote:
>>>> 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 fa6ba35..7ed4d49 100644
>>>> --- a/qm-pci-passthrough.adoc
>>>> +++ b/qm-pci-passthrough.adoc
>>>> @@ -389,6 +389,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: Set `intel_iommu=on` or `amd_iommu=on` depending on your
>>>> +CPU.
>>>
>>> And by "CPU" you mean kernel command line? ;-)
>>
>> Host-Requirement: Add `intel_iommu=on` or `amd_iommu=on`
>> depending on your CPU to your kernel command line.
>>
>> like this?
>>>
>>>> +
>>>> +VM-Requirement: For both Intel and AMD CPUs you will have to set
>>>> +`intel_iommu=on` as a Linux boot parameter in the vIOMMU-enabled-VM, because
>>>> +Qemu implements the Intel variant.
>>>
>>> ^ As mentioned, there does appear to be an amd_iommu device in the qemu
>>> code, so would the amd variant work?
>>>
>>> In my reply to the code patch I mentioned checking the host arch. But if
>>> you say we can use intel_iommu on AMD as well, I'd say, if both work,
>>> give the user a choice, otherwise we can of course just stick to the one
>>> that works ;-)
>>
>> intel_iommu works better on my AMD CPU than amd_iommu ;)
> 
> Can you define "better"?
> My main concern is that if we don't give users the option to choose, the
> only data point we have is yours ;-)
> If we explicitly mention that you can use one on the other in the docs,
> people can try it themselves and maybe we'll see some feedback on the
> forums etc.
> 
> However, I'm fine with a patch for only the intel version for now as we
> can always add an option later.
> 
>> Moreover it adds an extra AMDVI-PCI device that is using the first pci address.
>> `kvm: -device VGA,id=vga,bus=pcie.0,addr=0x1: PCI: slot 1 function 0 not available for VGA, in use by AMDVI-PCI,id=(null)`
> 
> For that I'd say, try to add the AMDVI-PCI device manually to an
> explicitly chosen slot. We need to avoid automatically added devices
> like the plague, because moving them later can break live snapshots (and
> windows).
> 
I manually added a AMDVI-PCI device with a explicitly chosen slot but
amd-iommu still adds an extra AMDVI-PCI device.
I do not see any way to prevent this or to change the address
of the additionally added AMDVI-PCI device (from amd-iommu).

I think amd-iommu is very impractical if we cannot set this slot manually.

>>
>> I cannot find any good documentation for amd_iommu but it also seems like
>> it has less features.
> 
> Less, or just not configurable? ;-)
> I mean, if it works it works ;-)
> 
>>
>> $ qemu-system-x86_64 -device 'amd-iommu,help'
>> amd-iommu options:
>>    device-iotlb=<bool>    -  (default: false)
>>    intremap=<OnOffAuto>   - on/off/auto (default: "auto")
>>    pt=<bool>              -  (default: true)
>> $ qemu-system-x86_64 -device 'intel-iommu,help'
>> intel-iommu options:
>>    aw-bits=<uint8>        -  (default: 39)
>>    caching-mode=<bool>    -  (default: false)
>>    device-iotlb=<bool>    -  (default: false)
>>    dma-drain=<bool>       -  (default: true)
>>    dma-translation=<bool> -  (default: true)
>>    eim=<OnOffAuto>        - on/off/auto (default: "auto")
>>    intremap=<OnOffAuto>   - on/off/auto (default: "auto")
>>    pt=<bool>              -  (default: true)
>>    snoop-control=<bool>   -  (default: false)
>>    version=<uint32>       -  (default: 0)
>>    x-buggy-eim=<bool>     -  (default: false)
>>    x-pasid-mode=<bool>    -  (default: false)
>>    x-scalable-mode=<bool> -  (default: false)




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

* Re: [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation
  2023-01-17 10:55         ` Markus Frank
@ 2023-01-17 15:01           ` Wolfgang Bumiller
  0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Bumiller @ 2023-01-17 15:01 UTC (permalink / raw)
  To: Markus Frank; +Cc: Proxmox VE development discussion

On Tue, Jan 17, 2023 at 11:55:47AM +0100, Markus Frank wrote:
> 
> 
> On 1/16/23 11:00, Wolfgang Bumiller wrote:
> > On Fri, Jan 13, 2023 at 02:31:36PM +0100, Markus Frank wrote:
> > > Moreover it adds an extra AMDVI-PCI device that is using the first pci address.
> > > `kvm: -device VGA,id=vga,bus=pcie.0,addr=0x1: PCI: slot 1 function 0 not available for VGA, in use by AMDVI-PCI,id=(null)`
> > 
> > For that I'd say, try to add the AMDVI-PCI device manually to an
> > explicitly chosen slot. We need to avoid automatically added devices
> > like the plague, because moving them later can break live snapshots (and
> > windows).
> > 
> I manually added a AMDVI-PCI device with a explicitly chosen slot but
> amd-iommu still adds an extra AMDVI-PCI device.
> I do not see any way to prevent this or to change the address
> of the additionally added AMDVI-PCI device (from amd-iommu).
> 
> I think amd-iommu is very impractical if we cannot set this slot manually.

Okay, let's just not provide it for now.




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

end of thread, other threads:[~2023-01-17 15:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 14:08 [pve-devel] [PATCH qemu-server v4 0/5] vIOMMU-Feature Markus Frank
2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 1/5] tests: replaced somemachine&someothermachine with q35&pc Markus Frank
2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 2/5] fix #3784: Parameter for guest vIOMMU & machine as property-string Markus Frank
2023-01-13  9:51   ` Wolfgang Bumiller
2022-11-25 14:08 ` [pve-devel] [PATCH qemu-server v4 3/5] added test-cases for new machine-syntax & viommu Markus Frank
2022-11-25 14:08 ` [pve-devel] [PATCH docs v4 4/5] added vIOMMU documentation Markus Frank
2023-01-13 10:09   ` Wolfgang Bumiller
2023-01-13 13:31     ` Markus Frank
2023-01-16 10:00       ` Wolfgang Bumiller
2023-01-17 10:55         ` Markus Frank
2023-01-17 15:01           ` Wolfgang Bumiller
2022-11-25 14:08 ` [pve-devel] [PATCH manager v4 5/5] ui: MachineEdit with viommu checkbox Markus Frank
2023-01-12 13:51 ` [pve-devel] [PATCH qemu-server v4 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