[PATCH v3 08/12] cpu_map: Add versioned Intel Icelake CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |   4 +
 src/cpu_map/meson.build   |   4 +
 src/cpu_map/x86_Icelake-Server-v3.xml | 103 +
 src/cpu_map/x86_Icelake-Server-v4.xml | 108 +
 src/cpu_map/x86_Icelake-Server-v5.xml | 109 ++
 src/cpu_map/x86_Icelake-Server-v6.xml | 109 ++
 .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml|   1 +
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |   3 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |   3 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|   3 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |   3 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |   3 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|   3 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |   4 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |   4 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|   4 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |   4 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |   4 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|   4 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |   4 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |   4 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |   4 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|   4 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |   4 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |   4 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|   4 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |   4 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |   4 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|   4 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |   4 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |   4 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|   4 +
 43 files changed, 552 insertions(+)
 create mode 100644 src/cpu_map/x86_Icelake-Server-v3.xml
 create mode 100644 src/cpu_map/x86_Icelake-Server-v4.xml
 create mode 100644 src/cpu_map/x86_Icelake-Server-v5.xml
 create mode 100644 src/cpu_map/x86_Icelake-Server-v6.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index ad6361ee51..c0971c9391 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -60,6 +60,10 @@
 
 
 
+
+
+
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index 7a3712280a..6e77f78b1c 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -59,6 +59,10 @@ cpumap_data = [
   'x86_Icelake-Client-noTSX.xml',
   'x86_Icelake-Client.xml',
   'x86_Icelake-Server-noTSX.xml',
+  'x86_Icelake-Server-v3.xml',
+  'x86_Icelake-Server-v4.xml',
+  'x86_Icelake-Server-v5.xml',
+  'x86_Icelake-Server-v6.xml',
   'x86_Icelake-Server.xml',
   'x86_IvyBridge-IBRS.xml',
   'x86_IvyBridge.xml',
diff --git a/src/cpu_map/x86_Icelake-Server-v3.xml 
b/src/cpu_map/x86_Icelake-Server-v3.xml
new file mode 100644
index 00..070951108a
--- /dev/null
+++ b/src/cpu_map/x86_Icelake-Server-v3.xml
@@ -0,0 +1,103 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/src/cpu_map/x86_Icelake-Server-v4.xml 
b/src/cpu_map/x86_Icelake-Server-v4.xml
new file mode 100644
index 00..a65271e801
--- /dev/null
+++ b/src/cpu_map/x86_Icelake-Server-v4.xml
@@ -0,0 +1,108 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 

[PATCH v3 10/12] cpu_map: Add versioned Intel Snowridge CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |  3 +
 src/cpu_map/meson.build   |  3 +
 src/cpu_map/x86_Snowridge-v2.xml  | 78 ++
 src/cpu_map/x86_Snowridge-v3.xml  | 80 +++
 src/cpu_map/x86_Snowridge-v4.xml  | 78 ++
 .../x86_64-cpuid-Atom-P5362-guest.xml |  3 +-
 .../x86_64-cpuid-Atom-P5362-json.xml  |  3 +-
 .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_4.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |  2 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |  2 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|  2 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |  3 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |  3 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|  3 +
 47 files changed, 331 insertions(+), 4 deletions(-)
 create mode 100644 src/cpu_map/x86_Snowridge-v2.xml
 create mode 100644 src/cpu_map/x86_Snowridge-v3.xml
 create mode 100644 src/cpu_map/x86_Snowridge-v4.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index 3d8be6e41a..449abbd8f3 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -67,6 +67,9 @@
 
 
 
+
+
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index a6db0b1503..073fd66bec 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -97,6 +97,9 @@ cpumap_data = [
   'x86_Skylake-Server-v4.xml',
   'x86_Skylake-Server-v5.xml',
   'x86_Skylake-Server.xml',
+  'x86_Snowridge-v2.xml',
+  'x86_Snowridge-v3.xml',
+  'x86_Snowridge-v4.xml',
   'x86_Snowridge.xml',
   'x86_vendors.xml',
   'x86_Westmere-IBRS.xml',
diff --git a/src/cpu_map/x86_Snowridge-v2.xml b/src/cpu_map/x86_Snowridge-v2.xml
new file mode 100644
index 00..59b7aafe8d
--- /dev/null
+++ b/src/cpu_map/x86_Snowridge-v2.xml
@@ -0,0 +1,78 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/src/cpu_map/x86_Snowridge-v3.xml b/src/cpu_map/x86_Snowridge-v3.xml
new file mode 100644
index 00..949c5d2633
--- /dev/null
+++ b/src/cpu_map/x86_Snowridge-v3.xml
@@ -0,0 +1,80 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/src/cpu_map/x86_Snowridge-v4.xml b/src/cpu_map/x86_Snowridge-v4.xml
new file mode 100644
index 00..818e75f90d
--- /dev/null
+++ b/src/cpu_map/x86_Snowridge-v4.xml
@@ -0,0 +1,78 @@
+
+
+  
+
+
+
+
+
+
+
+

[PATCH v3 12/12] cpu_map: Add versioned Dhyana CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |  1 +
 src/cpu_map/meson.build   |  1 +
 src/cpu_map/x86_Dhyana-v2.xml | 81 +++
 ..._64-cpuid-Hygon-C86-7185-32-core-guest.xml |  5 +-
 ...6_64-cpuid-Hygon-C86-7185-32-core-host.xml |  5 +-
 ...6_64-cpuid-Hygon-C86-7185-32-core-json.xml |  6 +-
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |  1 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |  1 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|  1 +
 31 files changed, 112 insertions(+), 12 deletions(-)
 create mode 100644 src/cpu_map/x86_Dhyana-v2.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index 9b3719c5ef..e643aa01be 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -95,6 +95,7 @@
 
 
 
+
   
 
   
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index 4b2a90fd74..e16a16c276 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -40,6 +40,7 @@ cpumap_data = [
   'x86_coreduo.xml',
   'x86_cpu64-rhel5.xml',
   'x86_cpu64-rhel6.xml',
+  'x86_Dhyana-v2.xml',
   'x86_Dhyana.xml',
   'x86_EPYC-IBPB.xml',
   'x86_EPYC.xml',
diff --git a/src/cpu_map/x86_Dhyana-v2.xml b/src/cpu_map/x86_Dhyana-v2.xml
new file mode 100644
index 00..d5568e77b3
--- /dev/null
+++ b/src/cpu_map/x86_Dhyana-v2.xml
@@ -0,0 +1,81 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-guest.xml 
b/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-guest.xml
index 8669e5bd1b..0b318b94c4 100644
--- a/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-guest.xml
+++ b/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-guest.xml
@@ -1,10 +1,9 @@
 
-  Dhyana
+  Dhyana-v2
   Hygon
   
   
   
-  
   
   
   
@@ -16,10 +15,8 @@
   
   
   
-  
   
   
-  
   
   
   
diff --git a/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-host.xml 
b/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-host.xml
index ddb14c0440..74c751ad1f 100644
--- a/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-host.xml
@@ -1,12 +1,11 @@
 
   x86_64
-  Dhyana
+  Dhyana-v2
   Hygon
   
   
   
   
-  
   
   
   
@@ -18,10 +17,8 @@
   
   
   
-  
   
   
-  
   
   
   
diff --git a/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-json.xml 
b/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-json.xml
index 0408d51c10..2ff92e2c15 100644
--- a/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-json.xml
+++ b/tests/cputestdata/x86_64-cpuid-Hygon-C86-7185-32-core-json.xml
@@ -1,5 +1,5 @@
 
-  Dhyana
+  Dhyana-v2
   Hygon
   
   
@@ -7,8 +7,6 @@
   
   
   
-  
-  
+  
   
-  
 
diff --git a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml 
b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
index 59276428c1..31c8a5d4ed 100644
--- a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
@@ -118,6 +118,7 @@
   EPYC-Milan
   EPYC-IBPB
   EPYC
+  Dhyana-v2
   Dhyana
   Cooperlake-v2
   Cooperlake
diff --git a/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml 
b/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
index eff9d4c8eb..b9e671e1f7 100644
--- a/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.

[PATCH v3 04/12] qemu: use canonical name for CPU models

2023-12-15 Thread Jonathon Jongsma
As described in detail in the commit "cpu_map: add canonical names to
existing CPU models", the unversioned CPU model names are not
migration-safe. If qemu makes the anticipated changes to CPU alias
mapping, an unversioned CPU model may be represented by different
underlying CPU models on different hosts. To avoid being susceptible to
this issue, use the new 'canonical_name' property of the CPU definition
to always specify a specific versioned CPU model version to qemu rather
than using CPU model aliases.

This canonical name is only used in the qemu backend and is not exposed
to the user in anyway. The libvirt CPU configuration will continue to
use existing unversioned model names in the domain xml for continuity.
But internally we will translate these to a specific version.

Signed-off-by: Jonathon Jongsma 
---
 src/qemu/qemu_command.c  | 5 -
 tests/qemuxml2argvdata/cpu-Haswell-noTSX.x86_64-latest.args  | 2 +-
 tests/qemuxml2argvdata/cpu-Haswell.x86_64-latest.args| 2 +-
 tests/qemuxml2argvdata/cpu-Haswell2.x86_64-latest.args   | 2 +-
 tests/qemuxml2argvdata/cpu-Haswell3.x86_64-latest.args   | 2 +-
 .../cpu-Icelake-Server-pconfig.x86_64-latest.args| 2 +-
 tests/qemuxml2argvdata/cpu-cache-disable3.x86_64-latest.args | 2 +-
 .../cpu-check-default-partial.x86_64-latest.args | 2 +-
 tests/qemuxml2argvdata/cpu-fallback.x86_64-5.2.0.args| 2 +-
 tests/qemuxml2argvdata/cpu-fallback.x86_64-8.0.0.args| 2 +-
 tests/qemuxml2argvdata/cpu-host-model-cmt.x86_64-latest.args | 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-4.2.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-5.0.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-5.1.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-5.2.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-6.0.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-6.1.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-6.2.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-7.0.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-7.1.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-7.2.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-8.0.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-8.1.0.args| 2 +-
 .../cpu-host-model-fallback-kvm.x86_64-latest.args   | 2 +-
 .../cpu-host-model-fallback-tcg.x86_64-7.2.0.args| 2 +-
 .../cpu-host-model-fallback-tcg.x86_64-8.0.0.args| 2 +-
 .../cpu-host-model-fallback-tcg.x86_64-8.1.0.args| 2 +-
 .../cpu-host-model-fallback-tcg.x86_64-latest.args   | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-4.2.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-5.0.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-5.1.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-5.2.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-6.0.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-6.1.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-6.2.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-7.0.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-7.1.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-7.2.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-8.0.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-8.1.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-kvm.x86_64-latest.args | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-4.2.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-5.0.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-5.1.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-5.2.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-6.0.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-6.1.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-6.2.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-7.0.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-7.1.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-7.2.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-8.0.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-8.1.0.args  | 2 +-
 .../cpu-host-model-nofallback-kvm.x86_64-latest.args | 2 +-
 .../cpu-host-model-nofallback-tcg.x86_64-7.2.0.args  | 2 +-
 .../cpu-host-model-nofallback-tcg.x86_64-8.0.0.args  | 2 +-
 .../cpu-host-model-nofallback-tcg.x86_64-8.1.0.args  | 2 +-
 .../cpu-host-model-nofallback-tcg.x86_64-latest.args | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-tcg.x86_64-7.2.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-host-model-tcg.x86_64-8.0.0.args  | 2 +-
 tests/qemuxml2argvdata/cpu-hos

[PATCH v3 07/12] cpu_map: Add versioned Intel Cascadelake CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |  3 +
 src/cpu_map/meson.build   |  3 +
 src/cpu_map/x86_Cascadelake-Server-v2.xml | 93 +++
 src/cpu_map/x86_Cascadelake-Server-v4.xml | 91 ++
 src/cpu_map/x86_Cascadelake-Server-v5.xml | 92 ++
 .../x86_64-cpuid-Xeon-Platinum-8268-guest.xml |  9 +-
 .../x86_64-cpuid-Xeon-Platinum-8268-host.xml  |  9 +-
 .../x86_64-cpuid-Xeon-Platinum-9242-guest.xml |  9 +-
 .../x86_64-cpuid-Xeon-Platinum-9242-host.xml  |  9 +-
 .../x86_64-cpuid-Xeon-Platinum-9242-json.xml  |  9 +-
 ..._64-cpuid-baseline-Cascadelake+Icelake.xml |  9 +-
 ...-cpuid-baseline-Cooperlake+Cascadelake.xml |  9 +-
 ...6_64-cpuid-baseline-Cooperlake+Icelake.xml |  9 +-
 .../domaincapsdata/qemu_4.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_4.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |  2 +
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |  2 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml|  2 +
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |  2 +
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |  2 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml|  2 +
 .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml  |  2 +
 .../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml  |  2 +
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml|  2 +
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |  3 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |  3 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|  3 +
 53 files changed, 399 insertions(+), 54 deletions(-)
 create mode 100644 src/cpu_map/x86_Cascadelake-Server-v2.xml
 create mode 100644 src/cpu_map/x86_Cascadelake-Server-v4.xml
 create mode 100644 src/cpu_map/x86_Cascadelake-Server-v5.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index a4fe2ec781..ad6361ee51 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -53,6 +53,9 @@
 
 
 
+
+
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index f6b95863b3..7a3712280a 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -29,6 +29,9 @@ cpumap_data = [
   'x86_Broadwell-noTSX.xml',
   'x86_Broadwell.xml',
   'x86_Cascadelake-Server-noTSX.xml',
+  'x86_Cascadelake-Server-v2.xml',
+  'x86_Cascadelake-Server-v4.xml',
+  'x86_Cascadelake-Server-v5.xml',
   'x86_Cascadelake-Server.xml',
   'x86_Conroe.xml',
   'x86_Cooperlake.xml',
diff --git a/src/cpu_map/x86_Cascadelake-Server-v2.xml 
b/src/cpu_map/x86_Cascadelake-Server-v2.xml
new file mode 100644
index 00..5152f0390b
--- /dev/null
+++ b/src/cpu_map/x86_Cascadelake-Server-v2.xml
@@ -0,0 +1,93 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/src/cpu_map/x86_Cascadelake-Server-v4.xml 
b/src/cpu_map/x86_Cascadelake-Server-v4.xml
new file mode 100644
index 00..b2173d1308
--- /dev/null
+++ b/src/cpu_map/x86_Cascadelake-Server-v4.xml
@@ -0,0 +1,91 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

[PATCH v3 05/12] cpu_map: Add versioned EPYC CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |   6 +
 src/cpu_map/meson.build   |   6 +
 src/cpu_map/x86_EPYC-Milan-v2.xml | 108 ++
 src/cpu_map/x86_EPYC-Rome-v2.xml  |  93 +++
 src/cpu_map/x86_EPYC-Rome-v3.xml  |  95 +++
 src/cpu_map/x86_EPYC-Rome-v4.xml  |  94 +++
 src/cpu_map/x86_EPYC-v3.xml   |  87 ++
 src/cpu_map/x86_EPYC-v4.xml   |  88 ++
 .../x86_64-cpuid-EPYC-7502-32-Core-host.xml   |   5 +-
 .../x86_64-cpuid-EPYC-7601-32-Core-guest.xml  |   9 +-
 ...6_64-cpuid-EPYC-7601-32-Core-ibpb-host.xml |   8 +-
 ...4-cpuid-Ryzen-7-1800X-Eight-Core-guest.xml |   9 +-
 .../domaincapsdata/qemu_5.0.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_5.0.0.x86_64.xml|   1 +
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml|   1 +
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml|   1 +
 .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |   2 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |   2 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |   2 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |   2 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|   2 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |  11 +-
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |   6 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|  11 +-
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |  11 +-
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |   6 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|  11 +-
 ...-host-model-fallback-kvm.x86_64-8.1.0.args |   2 +-
 ...host-model-fallback-kvm.x86_64-latest.args |   2 +-
 .../cpu-host-model-kvm.x86_64-8.1.0.args  |   2 +-
 .../cpu-host-model-kvm.x86_64-latest.args |   2 +-
 ...ost-model-nofallback-kvm.x86_64-8.1.0.args |   2 +-
 ...st-model-nofallback-kvm.x86_64-latest.args |   2 +-
 55 files changed, 686 insertions(+), 43 deletions(-)
 create mode 100644 src/cpu_map/x86_EPYC-Milan-v2.xml
 create mode 100644 src/cpu_map/x86_EPYC-Rome-v2.xml
 create mode 100644 src/cpu_map/x86_EPYC-Rome-v3.xml
 create mode 100644 src/cpu_map/x86_EPYC-Rome-v4.xml
 create mode 100644 src/cpu_map/x86_EPYC-v3.xml
 create mode 100644 src/cpu_map/x86_EPYC-v4.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index d2c5af5797..861edc3bb7 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -67,9 +67,15 @@
 
 
 
+
+
 
 
+
+
+
 
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index ae5293e85f..68e093e041 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -39,8 +39,14 @@ cpumap_data = [
   'x86_Dhyana.xml',
   'x86_EPYC-IBPB.xml',
   'x86_EPYC.xml',
+  'x86_EPYC-v3.xml',
+  'x86_EPYC-v4.xml',
   'x86_EPYC-Genoa.xml',
+  'x86_EPYC-Milan-v2.xml',
   'x86_EPYC-Milan.xml',
+  'x86_EPYC-Rome-v2.xml',
+  'x86_EPYC-Rome-v3.xml',
+  'x86_EPYC-Rome-v4.xml',
   'x86_EPYC-Rome.xml',
   'x86_features.xml',
   'x86_Haswell-IBRS.xml',
diff --git a/src/cpu_map/x86_EPYC-Milan-v2.xml 
b/src/cpu_map/x86_EPYC-Milan-v2.xml
new file mode 100644
index 00..4cadba2325
--- /dev/null
+++ b/src/cpu_map/x86_EPYC-Milan-v2.xml
@@ -0,0 +1,108 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

[PATCH v3 06/12] cpu_map: Add versioned Intel Skylake CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |  3 +
 src/cpu_map/meson.build   |  3 +
 src/cpu_map/x86_Skylake-Client-v4.xml | 77 +
 src/cpu_map/x86_Skylake-Server-v4.xml | 83 ++
 src/cpu_map/x86_Skylake-Server-v5.xml | 85 +++
 .../domaincapsdata/qemu_5.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_5.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_5.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_5.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_6.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_6.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |  3 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |  3 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|  3 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |  3 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |  3 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|  3 +
 39 files changed, 335 insertions(+)
 create mode 100644 src/cpu_map/x86_Skylake-Client-v4.xml
 create mode 100644 src/cpu_map/x86_Skylake-Server-v4.xml
 create mode 100644 src/cpu_map/x86_Skylake-Server-v5.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index 861edc3bb7..a4fe2ec781 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -45,9 +45,12 @@
 
 
 
+
 
 
 
+
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index 68e093e041..f6b95863b3 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -82,9 +82,12 @@ cpumap_data = [
   'x86_SapphireRapids.xml',
   'x86_Skylake-Client-IBRS.xml',
   'x86_Skylake-Client-noTSX-IBRS.xml',
+  'x86_Skylake-Client-v4.xml',
   'x86_Skylake-Client.xml',
   'x86_Skylake-Server-IBRS.xml',
   'x86_Skylake-Server-noTSX-IBRS.xml',
+  'x86_Skylake-Server-v4.xml',
+  'x86_Skylake-Server-v5.xml',
   'x86_Skylake-Server.xml',
   'x86_Snowridge.xml',
   'x86_vendors.xml',
diff --git a/src/cpu_map/x86_Skylake-Client-v4.xml 
b/src/cpu_map/x86_Skylake-Client-v4.xml
new file mode 100644
index 00..038ac376b6
--- /dev/null
+++ b/src/cpu_map/x86_Skylake-Client-v4.xml
@@ -0,0 +1,77 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/src/cpu_map/x86_Skylake-Server-v4.xml 
b/src/cpu_map/x86_Skylake-Server-v4.xml
new file mode 100644
index 00..6c864f6b9c
--- /dev/null
+++ b/src/cpu_map/x86_Skylake-Server-v4.xml
@@ -0,0 +1,83 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/src/cpu_map/x86_Skylake-Server-v5.xml 
b/src/cpu_map/x86_Skylake-Server-v5.xml
new file mode 100644
index 00..f3d49fb5d2
--- /dev/null
+++ b/src/cpu_map/x86_Skylake-Server-v5.xml
@@ -0,0 +1,85 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

[PATCH v3 09/12] cpu_map: Add versioned Intel Cooperlake CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |  1 +
 src/cpu_map/meson.build   |  1 +
 src/cpu_map/x86_Cooperlake-v2.xml | 98 +++
 .../x86_64-cpuid-Cooperlake-host.xml  |  3 +-
 .../domaincapsdata/qemu_6.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_6.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_6.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_6.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_7.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_7.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_7.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_7.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_7.2.0-q35.x86_64.xml  |  1 +
 .../qemu_7.2.0-tcg.x86_64+hvf.xml |  1 +
 .../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_7.2.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_8.0.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_8.0.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_8.0.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|  1 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |  1 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |  1 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|  1 +
 29 files changed, 126 insertions(+), 2 deletions(-)
 create mode 100644 src/cpu_map/x86_Cooperlake-v2.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index c0971c9391..3d8be6e41a 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -65,6 +65,7 @@
 
 
 
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index 6e77f78b1c..a6db0b1503 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -34,6 +34,7 @@ cpumap_data = [
   'x86_Cascadelake-Server-v5.xml',
   'x86_Cascadelake-Server.xml',
   'x86_Conroe.xml',
+  'x86_Cooperlake-v2.xml',
   'x86_Cooperlake.xml',
   'x86_core2duo.xml',
   'x86_coreduo.xml',
diff --git a/src/cpu_map/x86_Cooperlake-v2.xml 
b/src/cpu_map/x86_Cooperlake-v2.xml
new file mode 100644
index 00..bf0ba626d6
--- /dev/null
+++ b/src/cpu_map/x86_Cooperlake-v2.xml
@@ -0,0 +1,98 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/tests/cputestdata/x86_64-cpuid-Cooperlake-host.xml 
b/tests/cputestdata/x86_64-cpuid-Cooperlake-host.xml
index 8dfc62a5c1..dea9bc9b9f 100644
--- a/tests/cputestdata/x86_64-cpuid-Cooperlake-host.xml
+++ b/tests/cputestdata/x86_64-cpuid-Cooperlake-host.xml
@@ -1,6 +1,6 @@
 
   x86_64
-  Cooperlake
+  Cooperlake-v2
   Intel
   
   
@@ -27,7 +27,6 @@
   
   
   
-  
   
   
   
diff --git a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml 
b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
index 3385f64440..ec469d2ef2 100644
--- a/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0-q35.x86_64.xml
@@ -117,6 +117,7 @@
   EPYC-IBPB
   EPYC
   Dhyana
+  Cooperlake-v2
   Cooperlake
   Conroe
   Cascadelake-Server-v5
diff --git a/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml 
b/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
index b26fad77d0..ecdf591638 100644
--- a/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0-tcg.x86_64.xml
@@ -129,6 +129,7 @@
   EPYC-IBPB
   EPYC
   Dhyana
+  Cooperlake-v2
   Cooperlake
   Conroe
   Cascadelake-Server-v5
diff --git a/tests/domaincapsdata/qemu_6.1.0.x86_64.xml 
b/tests/domaincapsdata/qemu_6.1.0.x86_64.xml
index 0c02963502..5059e61c87 100644
--- a/tests/domaincapsdata/qemu_6.1.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.1.0.x86_64.xml
@@ -116,6 +116,7 @@
   EPYC-IBPB
   EPYC
   Dhyana
+  Cooperlake-v2
   Cooperlake
   Conroe
   Cascadelake-Server-v5
diff --git a/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml 
b/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml
index bc93fb8412..d4d90817b1 100644
--- a/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_6.2.0-q35.x86_64.xml
@@ -117,6 +117,7 @@
   EPYC-IBPB
   EPYC
   Dhyana
+  Cooperlake-v2
   Cooperlake
   Conroe
   

[PATCH v3 11/12] cpu_map: Add versioned Intel SapphireRapids CPUs

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/index.xml |   1 +
 src/cpu_map/meson.build   |   1 +
 src/cpu_map/x86_SapphireRapids-v2.xml | 125 ++
 .../domaincapsdata/qemu_8.1.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_8.1.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_8.1.0.x86_64.xml|   1 +
 .../domaincapsdata/qemu_8.2.0-q35.x86_64.xml  |   1 +
 .../domaincapsdata/qemu_8.2.0-tcg.x86_64.xml  |   1 +
 tests/domaincapsdata/qemu_8.2.0.x86_64.xml|   1 +
 9 files changed, 133 insertions(+)
 create mode 100644 src/cpu_map/x86_SapphireRapids-v2.xml

diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml
index 449abbd8f3..9b3719c5ef 100644
--- a/src/cpu_map/index.xml
+++ b/src/cpu_map/index.xml
@@ -71,6 +71,7 @@
 
 
 
+
 
 
 
diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build
index 073fd66bec..4b2a90fd74 100644
--- a/src/cpu_map/meson.build
+++ b/src/cpu_map/meson.build
@@ -87,6 +87,7 @@ cpumap_data = [
   'x86_qemu64.xml',
   'x86_SandyBridge-IBRS.xml',
   'x86_SandyBridge.xml',
+  'x86_SapphireRapids-v2.xml',
   'x86_SapphireRapids.xml',
   'x86_Skylake-Client-IBRS.xml',
   'x86_Skylake-Client-noTSX-IBRS.xml',
diff --git a/src/cpu_map/x86_SapphireRapids-v2.xml 
b/src/cpu_map/x86_SapphireRapids-v2.xml
new file mode 100644
index 00..0d90d50f5f
--- /dev/null
+++ b/src/cpu_map/x86_SapphireRapids-v2.xml
@@ -0,0 +1,125 @@
+
+
+  
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  
+
diff --git a/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml 
b/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml
index c80455a6b5..4067720049 100644
--- a/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.1.0-q35.x86_64.xml
@@ -98,6 +98,7 @@
   Skylake-Client-noTSX-IBRS
   Skylake-Client-IBRS
   Skylake-Client
+  SapphireRapids-v2
   SapphireRapids
   SandyBridge-IBRS
   SandyBridge
diff --git a/tests/domaincapsdata/qemu_8.1.0-tcg.x86_64.xml 
b/tests/domaincapsdata/qemu_8.1.0-tcg.x86_64.xml
index ee67181b3e..7c836af7e6 100644
--- a/tests/domaincapsdata/qemu_8.1.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.1.0-tcg.x86_64.xml
@@ -99,6 +99,7 @@
   Skylake-Client-noTSX-IBRS
   Skylake-Client-IBRS
   Skylake-Client
+  SapphireRapids-v2
   SapphireRapids
   SandyBridge-IBRS
   SandyBridge
diff --git a/tests/domaincapsdata/qemu_8.1.0.x86_64.xml 
b/tests/domaincapsdata/qemu_8.1.0.x86_64.xml
index 00b6d45314..6ff2ebbde8 100644
--- a/tests/domaincapsdata/qemu_8.1.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.1.0.x86_64.xml
@@ -97,6 +97,7 @@
   Skylake-Client-noTSX-IBRS
   Skylake-Client-IBRS
   Skylake-Client
+  SapphireRapids-v2
   SapphireRapids
   SandyBridge-IBRS
   SandyBridge
diff --git a/tests/domaincapsdata/qemu_8.2.0-q35.x86_64.xml 
b/tests/domaincapsdata/qemu_8.2.0-q35.x86_64.xml
index 4aebd4a128..8e504436cf 100644
--- a/tests/domaincapsdata/qemu_8.2.0-q35.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.2.0-q35.x86_64.xml
@@ -99,6 +99,7 @@
   Skylake-Client-noTSX-IBRS
   Skylake-Client-IBRS
   Skylake-Client
+  SapphireRapids-v2
   SapphireRapids
   SandyBridge-IBRS
   SandyBridge
diff --git a/tests/domaincapsdata/qemu_8.2.0-tcg.x86_64.xml 
b/tests/domaincapsdata/qemu_8.2.0-tcg.x86_64.xml
index c9fc385bfa..7f0b057d97 100644
--- a/tests/domaincapsdata/qemu_8.2.0-tcg.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.2.0-tcg.x86_64.xml
@@ -98,6 +98,7 @@
   Skylake-Client-noTSX-IBRS
   Skylake-Client-IBRS
   Skylake-Client
+  SapphireRapids-v2
   SapphireRapids
   SandyBridge-IBRS
   SandyBridge
diff --git a/tests/domaincapsdata/qemu_8.2.0.x86_64.xml 
b/tests/domaincapsdata/qemu_8.2.0.x86_64.xml
index 0e424db1d8..0f43f5b543 100644
--- a/tests/domaincapsdata/qemu_8.2.0.x86_64.xml
+++ b/tests/domaincapsdata/qemu_8.2.0.x86_64.xml
@@ -98,6 +98,7 @@
   Skylake-Client-noTSX-IBRS
   Skylake-Client-IBRS
   Skylake-Client
+  SapphireRapids-v2
   SapphireRapids
   SandyBridge-IBRS
   SandyBridge
-- 
2.41.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 02/12] cpu_map: add canonical names to existing CPU models

2023-12-15 Thread Jonathon Jongsma
Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/x86_Broadwell-IBRS.xml| 1 +
 src/cpu_map/x86_Broadwell-noTSX-IBRS.xml  | 1 +
 src/cpu_map/x86_Broadwell-noTSX.xml   | 1 +
 src/cpu_map/x86_Broadwell.xml | 1 +
 src/cpu_map/x86_Cascadelake-Server-noTSX.xml  | 1 +
 src/cpu_map/x86_Cascadelake-Server.xml| 1 +
 src/cpu_map/x86_Cooperlake.xml| 1 +
 src/cpu_map/x86_Dhyana.xml| 1 +
 src/cpu_map/x86_EPYC-IBPB.xml | 1 +
 src/cpu_map/x86_EPYC-Milan.xml| 1 +
 src/cpu_map/x86_EPYC-Rome.xml | 1 +
 src/cpu_map/x86_EPYC.xml  | 1 +
 src/cpu_map/x86_Haswell-IBRS.xml  | 1 +
 src/cpu_map/x86_Haswell-noTSX-IBRS.xml| 1 +
 src/cpu_map/x86_Haswell-noTSX.xml | 1 +
 src/cpu_map/x86_Haswell.xml   | 1 +
 src/cpu_map/x86_Icelake-Server-noTSX.xml  | 1 +
 src/cpu_map/x86_Icelake-Server.xml| 1 +
 src/cpu_map/x86_IvyBridge-IBRS.xml| 1 +
 src/cpu_map/x86_IvyBridge.xml | 1 +
 src/cpu_map/x86_Nehalem-IBRS.xml  | 1 +
 src/cpu_map/x86_Nehalem.xml   | 1 +
 src/cpu_map/x86_SandyBridge-IBRS.xml  | 1 +
 src/cpu_map/x86_SandyBridge.xml   | 1 +
 src/cpu_map/x86_SapphireRapids.xml| 1 +
 src/cpu_map/x86_Skylake-Client-IBRS.xml   | 1 +
 src/cpu_map/x86_Skylake-Client-noTSX-IBRS.xml | 1 +
 src/cpu_map/x86_Skylake-Client.xml| 1 +
 src/cpu_map/x86_Skylake-Server-IBRS.xml   | 1 +
 src/cpu_map/x86_Skylake-Server-noTSX-IBRS.xml | 1 +
 src/cpu_map/x86_Skylake-Server.xml| 1 +
 src/cpu_map/x86_Snowridge.xml | 1 +
 src/cpu_map/x86_Westmere-IBRS.xml | 1 +
 src/cpu_map/x86_Westmere.xml  | 1 +
 34 files changed, 34 insertions(+)

diff --git a/src/cpu_map/x86_Broadwell-IBRS.xml 
b/src/cpu_map/x86_Broadwell-IBRS.xml
index 9033d5fcd5..13568eac81 100644
--- a/src/cpu_map/x86_Broadwell-IBRS.xml
+++ b/src/cpu_map/x86_Broadwell-IBRS.xml
@@ -1,5 +1,6 @@
 
   
+Broadwell-v3
 
  
  
diff --git a/src/cpu_map/x86_Broadwell-noTSX-IBRS.xml 
b/src/cpu_map/x86_Broadwell-noTSX-IBRS.xml
index c044b60e36..4ec35ce3a2 100644
--- a/src/cpu_map/x86_Broadwell-noTSX-IBRS.xml
+++ b/src/cpu_map/x86_Broadwell-noTSX-IBRS.xml
@@ -1,5 +1,6 @@
 
   
+Broadwell-v4
 
  
  
diff --git a/src/cpu_map/x86_Broadwell-noTSX.xml 
b/src/cpu_map/x86_Broadwell-noTSX.xml
index 637f29ba1c..3fed34e3a4 100644
--- a/src/cpu_map/x86_Broadwell-noTSX.xml
+++ b/src/cpu_map/x86_Broadwell-noTSX.xml
@@ -1,5 +1,6 @@
 
   
+Broadwell-v2
 
  
  
diff --git a/src/cpu_map/x86_Broadwell.xml b/src/cpu_map/x86_Broadwell.xml
index 82939a4509..79c96c3857 100644
--- a/src/cpu_map/x86_Broadwell.xml
+++ b/src/cpu_map/x86_Broadwell.xml
@@ -1,5 +1,6 @@
 
   
+Broadwell-v1
 
  
  
diff --git a/src/cpu_map/x86_Cascadelake-Server-noTSX.xml 
b/src/cpu_map/x86_Cascadelake-Server-noTSX.xml
index bfd4629836..e1b2a820dc 100644
--- a/src/cpu_map/x86_Cascadelake-Server-noTSX.xml
+++ b/src/cpu_map/x86_Cascadelake-Server-noTSX.xml
@@ -1,5 +1,6 @@
 
   
+Cascadelake-Server-v3
 
  
 
diff --git a/src/cpu_map/x86_Cascadelake-Server.xml 
b/src/cpu_map/x86_Cascadelake-Server.xml
index 335e9cb584..4e72518e0d 100644
--- a/src/cpu_map/x86_Cascadelake-Server.xml
+++ b/src/cpu_map/x86_Cascadelake-Server.xml
@@ -1,5 +1,6 @@
 
   
+Cascadelake-Server-v1
 
  
 
diff --git a/src/cpu_map/x86_Cooperlake.xml b/src/cpu_map/x86_Cooperlake.xml
index ceca687334..d2967daf3b 100644
--- a/src/cpu_map/x86_Cooperlake.xml
+++ b/src/cpu_map/x86_Cooperlake.xml
@@ -1,5 +1,6 @@
 
   
+Cooperlake-v1
 
  
 
diff --git a/src/cpu_map/x86_Dhyana.xml b/src/cpu_map/x86_Dhyana.xml
index cfde07f99f..a7fb540973 100644
--- a/src/cpu_map/x86_Dhyana.xml
+++ b/src/cpu_map/x86_Dhyana.xml
@@ -1,5 +1,6 @@
 
   
+Dhyana-v1
 
  
 
diff --git a/src/cpu_map/x86_EPYC-IBPB.xml b/src/cpu_map/x86_EPYC-IBPB.xml
index fc5aadf52e..28f0113392 100644
--- a/src/cpu_map/x86_EPYC-IBPB.xml
+++ b/src/cpu_map/x86_EPYC-IBPB.xml
@@ -1,5 +1,6 @@
 
   
+EPYC-v2
 
  
 
diff --git a/src/cpu_map/x86_EPYC-Milan.xml b/src/cpu_map/x86_EPYC-Milan.xml
index 3055e175fa..0dfdbb5b4b 100644
--- a/src/cpu_map/x86_EPYC-Milan.xml
+++ b/src/cpu_map/x86_EPYC-Milan.xml
@@ -1,5 +1,6 @@
 
   
+EPYC-Milan-v1
 
 
 
diff --git a/src/cpu_map/x86_EPYC-Rome.xml b/src/cpu_map/x86_EPYC-Rome.xml
index e54d0a48d8..794f3a8ff6 100644
--- a/src/cpu_map/x86_EPYC-Rome.xml
+++ b/src/cpu_map/x86_EPYC-Rome.xml
@@ -1,5 +1,6 @@
 
   
+EPYC-Rome-v1
 
 
 
diff --git a/src/cpu_map/x86_EPYC.xml b/src/cpu_map/x86_EPYC.xml
index 3b406de37a..852ca047e4 100644
--- a/src/cpu_map/x86_EPYC.xml
+++ b/src/cpu_map/x86_EPYC.xml
@@ -1,5 +1,6 @@
 
   
+EPYC-v1
 
  
 
diff --git a/src/cpu_map/x86_Haswell-IBRS.xml

[PATCH v3 03/12] cpu: parse the canonical name from the cpu model

2023-12-15 Thread Jonathon Jongsma
Recent changes have added a 'canonical_name' field to the xml
definitions for our CPU models. Parse this field into the C structure
and pass it around where necessary.
---
 src/conf/cpu_conf.c |  3 +++
 src/conf/cpu_conf.h |  1 +
 src/cpu/cpu_x86.c   | 24 
 3 files changed, 28 insertions(+)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 7abe489733..a771893956 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -113,6 +113,7 @@ void ATTRIBUTE_NONNULL(1)
 virCPUDefFreeModel(virCPUDef *def)
 {
 VIR_FREE(def->model);
+VIR_FREE(def->canonical_model);
 VIR_FREE(def->vendor);
 VIR_FREE(def->vendor_id);
 virCPUDefFreeFeatures(def);
@@ -161,6 +162,7 @@ virCPUDefCopyModelFilter(virCPUDef *dst,
 
 dst->features = g_new0(virCPUFeatureDef, src->nfeatures);
 dst->model = g_strdup(src->model);
+dst->canonical_model = g_strdup(src->canonical_model);
 dst->vendor = g_strdup(src->vendor);
 dst->vendor_id = g_strdup(src->vendor_id);
 dst->microcodeVersion = src->microcodeVersion;
@@ -211,6 +213,7 @@ virCPUDefStealModel(virCPUDef *dst,
 virCPUDefFreeModel(dst);
 
 dst->model = g_steal_pointer(&src->model);
+dst->canonical_model = g_steal_pointer(&src->canonical_model);
 dst->features = g_steal_pointer(&src->features);
 dst->microcodeVersion = src->microcodeVersion;
 dst->nfeatures_max = src->nfeatures_max;
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 3e4c53675c..ba8dab6c7f 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -142,6 +142,7 @@ struct _virCPUDef {
 virCPUCheck check;
 virArch arch;
 char *model;
+char *canonical_model;
 char *vendor_id;/* vendor id returned by CPUID in the guest */
 int fallback;   /* enum virCPUFallback */
 char *vendor;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 8d0e3947ce..70800d9579 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -142,6 +142,7 @@ struct _virCPUx86Signatures {
 typedef struct _virCPUx86Model virCPUx86Model;
 struct _virCPUx86Model {
 char *name;
+char *canonical_name;
 bool decodeHost;
 bool decodeGuest;
 virCPUx86Vendor *vendor;
@@ -864,6 +865,7 @@ x86DataToCPU(const virCPUx86Data *data,
 cpu = virCPUDefNew();
 
 cpu->model = g_strdup(model->name);
+cpu->canonical_model = g_strdup(model->canonical_name);
 
 x86DataCopy(©, data);
 x86DataCopy(&modelData, &model->data);
@@ -1281,6 +1283,7 @@ x86ModelFree(virCPUx86Model *model)
 return;
 
 g_free(model->name);
+g_free(model->canonical_name);
 virCPUx86SignaturesFree(model->signatures);
 virCPUx86DataClear(&model->data);
 g_strfreev(model->removedFeatures);
@@ -1296,6 +1299,7 @@ x86ModelCopy(virCPUx86Model *model)
 
 copy = g_new0(virCPUx86Model, 1);
 copy->name = g_strdup(model->name);
+copy->canonical_name = g_strdup(model->canonical_name);
 copy->signatures = virCPUx86SignaturesCopy(model->signatures);
 x86DataCopy(©->data, &model->data);
 copy->removedFeatures = g_strdupv(model->removedFeatures);
@@ -1451,6 +1455,17 @@ x86ModelCompare(virCPUx86Model *model1,
 }
 
 
+static int
+x86ModelParseCanonicalName(virCPUx86Model *model,
+   xmlXPathContextPtr ctxt)
+{
+if (!(model->canonical_name = 
virXPathString("string(./canonical_name[1])", ctxt)))
+model->canonical_name = g_strdup(model->name);
+
+return 0;
+}
+
+
 static int
 x86ModelParseDecode(virCPUx86Model *model,
 xmlXPathContextPtr ctxt)
@@ -1668,6 +1683,9 @@ x86ModelParse(xmlXPathContextPtr ctxt,
 model = g_new0(virCPUx86Model, 1);
 model->name = g_strdup(name);
 
+if (x86ModelParseCanonicalName(model, ctxt) < 0)
+return -1;
+
 if (x86ModelParseDecode(model, ctxt) < 0)
 return -1;
 
@@ -2268,6 +2286,7 @@ x86Decode(virCPUDef *cpu,
   sigFamily, sigModel, sigStepping);
 
 cpu->model = g_steal_pointer(&cpuModel->model);
+cpu->canonical_model = g_steal_pointer(&cpuModel->canonical_model);
 cpu->features = g_steal_pointer(&cpuModel->features);
 cpu->nfeatures = cpuModel->nfeatures;
 cpuModel->nfeatures = 0;
@@ -3010,6 +3029,11 @@ virCPUx86Update(virCPUDef *guest,
 return -1;
 }
 
+if (guestModel->canonical_name) {
+g_free(guest->canonical_model);
+guest->canonical_model = g_strdup(guestModel->canonical_name);
+}
+
 if (virCPUx86DisableRemovedFeatures(guest, guestModel) < 0)
 return -1;
 
-- 
2.41.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 00/12] Improve versioned CPU support in libvirt

2023-12-15 Thread Jonathon Jongsma
For SEV-SNP support we will need to be able to specify versioned CPU models
that are not yet available in libvirt. Rather than just adding a versioned CPU
or two that would satisfy that immediate need, I decided to try to add
versioned CPUs in a more standard way. This series generates CPU definitions
for all cpu versions that are defined in upstream qemu (at least for
recent Intel and AMD CPUs).

libvirt already provides a select subset of these versions as configurable CPU
models. But we only include the ones that have defined aliases in qemu, such as
EPYC-IBPB. After this patchset, all verisioned cpu models supported by qemu
will be available in libvirt.

In addition to adding these new versioned models, based on feedback from Daniel
Berrange, I've also translated all CPU model aliases to a specific version when
specifying a CPU model to qemu. This means that we will no longer specify e.g.
'-cpu EPYC' to qemu, but will rather specify '-cpu EPYC-v1'

Changes in v3:
 - handle unversioned aliases

Changes in v2:
 - don't make any changes to existing CPU models
 - drop concept of aliases from libvirt and only provide new versioned models
   that aren't already available via their qemu alias.

Jonathon Jongsma (12):
  cpu_map: update script to handle versioned CPUs
  cpu_map: add canonical names to existing CPU models
  cpu: parse the canonical name from the cpu model
  qemu: use canonical name for CPU models
  cpu_map: Add versioned EPYC CPUs
  cpu_map: Add versioned Intel Skylake CPUs
  cpu_map: Add versioned Intel Cascadelake CPUs
  cpu_map: Add versioned Intel Icelake CPUs
  cpu_map: Add versioned Intel Cooperlake CPUs
  cpu_map: Add versioned Intel Snowridge CPUs
  cpu_map: Add versioned Intel SapphireRapids CPUs
  cpu_map: Add versioned Dhyana CPUs

 src/conf/cpu_conf.c   |   3 +
 src/conf/cpu_conf.h   |   1 +
 src/cpu/cpu_x86.c |  24 
 src/cpu_map/index.xml |  22 +++
 src/cpu_map/meson.build   |  22 +++
 src/cpu_map/sync_qemu_models_i386.py  |  42 --
 src/cpu_map/x86_Broadwell-IBRS.xml|   1 +
 src/cpu_map/x86_Broadwell-noTSX-IBRS.xml  |   1 +
 src/cpu_map/x86_Broadwell-noTSX.xml   |   1 +
 src/cpu_map/x86_Broadwell.xml |   1 +
 src/cpu_map/x86_Cascadelake-Server-noTSX.xml  |   1 +
 src/cpu_map/x86_Cascadelake-Server-v2.xml |  93 +
 src/cpu_map/x86_Cascadelake-Server-v4.xml |  91 +
 src/cpu_map/x86_Cascadelake-Server-v5.xml |  92 +
 src/cpu_map/x86_Cascadelake-Server.xml|   1 +
 src/cpu_map/x86_Cooperlake-v2.xml |  98 ++
 src/cpu_map/x86_Cooperlake.xml|   1 +
 src/cpu_map/x86_Dhyana-v2.xml |  81 
 src/cpu_map/x86_Dhyana.xml|   1 +
 src/cpu_map/x86_EPYC-IBPB.xml |   1 +
 src/cpu_map/x86_EPYC-Milan-v2.xml | 108 +++
 src/cpu_map/x86_EPYC-Milan.xml|   1 +
 src/cpu_map/x86_EPYC-Rome-v2.xml  |  93 +
 src/cpu_map/x86_EPYC-Rome-v3.xml  |  95 +
 src/cpu_map/x86_EPYC-Rome-v4.xml  |  94 +
 src/cpu_map/x86_EPYC-Rome.xml |   1 +
 src/cpu_map/x86_EPYC-v3.xml   |  87 
 src/cpu_map/x86_EPYC-v4.xml   |  88 
 src/cpu_map/x86_EPYC.xml  |   1 +
 src/cpu_map/x86_Haswell-IBRS.xml  |   1 +
 src/cpu_map/x86_Haswell-noTSX-IBRS.xml|   1 +
 src/cpu_map/x86_Haswell-noTSX.xml |   1 +
 src/cpu_map/x86_Haswell.xml   |   1 +
 src/cpu_map/x86_Icelake-Server-noTSX.xml  |   1 +
 src/cpu_map/x86_Icelake-Server-v3.xml | 103 +++
 src/cpu_map/x86_Icelake-Server-v4.xml | 108 +++
 src/cpu_map/x86_Icelake-Server-v5.xml | 109 +++
 src/cpu_map/x86_Icelake-Server-v6.xml | 109 +++
 src/cpu_map/x86_Icelake-Server.xml|   1 +
 src/cpu_map/x86_IvyBridge-IBRS.xml|   1 +
 src/cpu_map/x86_IvyBridge.xml |   1 +
 src/cpu_map/x86_Nehalem-IBRS.xml  |   1 +
 src/cpu_map/x86_Nehalem.xml   |   1 +
 src/cpu_map/x86_SandyBridge-IBRS.xml  |   1 +
 src/cpu_map/x86_SandyBridge.xml   |   1 +
 src/cpu_map/x86_SapphireRapids-v2.xml | 125 ++
 src/cpu_map/x86_SapphireRapids.xml|   1 +
 src/cpu_map/x86_Skylake-Client-IBRS.xml   |   1 +
 src/cpu_map/x86_Skylake-Client-noTSX-IBRS.xml |   1 +
 src/cpu_map/x86_Skylake-Client-v4.xml |  77 +++
 src/cpu_map/x86_Skylake-Client.xml|   1 +
 src/cpu_map/x86_Skylake-Server-IBRS.xml   |   1 +
 src/cpu_map/x86_Skylake-Server-noTSX-IBRS.xml |   1 +
 src/cpu_map/x86_Skylake-Server-v4.xml |  83 
 src/cp

[PATCH v3 01/12] cpu_map: update script to handle versioned CPUs

2023-12-15 Thread Jonathon Jongsma
Previously, the script only generated the parent CPU and any versions
that had a defined alias. The script now generates all CPU versions. Any
version that had a defined alias will continue to use that alias, but
those without aliases will use the generated name $BASECPUNAME-vN.

The reason for this change is two-fold. First, we need to add new models
that support new features (such as SEV-SNP). To deal with this, the
script now generates model definitions for all versions.

But we also need to ensure that our CPU definitions are migration-safe.
To deal with this issue we need to make sure we're always using the
canonical versioned names for CPUs.

Qemu documentation states that unversioned names for CPU models (e.g.
'EPYC') are actually aliases to a specific versioned CPU model (e.g.
'EPYC-v1'). The documentation further states that the specific version
targeted by the alias may change based on the machine type of the
domain. Management software such as libvirt is directed to translate
these aliases to a concrete version in order to make sure that the CPU
definition is safe when migrating between different qemu versions that
may make different choices for which underlying versioned model
represents the alias.

In practice, at the time of writing qemu always maps the unversioned
aliases to the -v1 model. And libvirt's CPU model definitions also
assume that this is the case. For example, the 'x86_EPYC.xml' file
contains the features that are defined for the EPYC-v1 inside of qemu.
But if qemu ever changes their alias mapping, libvirt's idea of what an
'EPYC' CPU means and qemu's idea of what an 'EPYC' CPU means will no
longer match. So when choosing a CPU model for a domain, we should
always pass the canonical versioned name to libvirt rather than the
unversioned alias. To enable this, the script will generate a new
'canonical_name' field to the CPU model xml definition.

Signed-off-by: Jonathon Jongsma 
---
 src/cpu_map/sync_qemu_models_i386.py | 42 ++--
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/cpu_map/sync_qemu_models_i386.py 
b/src/cpu_map/sync_qemu_models_i386.py
index 1c6a2d4d27..7fd62eba4a 100755
--- a/src/cpu_map/sync_qemu_models_i386.py
+++ b/src/cpu_map/sync_qemu_models_i386.py
@@ -322,31 +322,55 @@ def expand_model(model):
 different fields and may have differing versions into several libvirt-
 friendly cpu models."""
 
-result = {
-"name": model.pop(".name"),
+basename = model.pop(".name")
+parent = {
+"name": basename,
 "vendor": translate_vendor(model.pop(".vendor")),
 "features": set(),
 "extra": dict()}
 
 if ".family" in model and ".model" in model:
-result["family"] = model.pop(".family")
-result["model"] = model.pop(".model")
+parent["family"] = model.pop(".family")
+parent["model"] = model.pop(".model")
 
 for k in [k for k in model if k.startswith(".features")]:
 v = model.pop(k)
 for feature in v.split():
 translated = translate_feature(feature)
 if translated:
-result["features"].add(translated)
+parent["features"].add(translated)
 
 versions = model.pop(".versions", [])
 for k, v in model.items():
-result["extra"]["model" + k] = v
-yield result
+parent["extra"]["model" + k] = v
+
+if not versions:
+yield parent
+return
+
+result = parent
 
 for version in versions:
+# each version builds on the previous one
 result = copy.deepcopy(result)
-result["name"] = version.pop(".alias", result["name"])
+vnum = int(version.pop(".version"))
+vname = "{}-v{}".format(basename, vnum)
+result["canonical_name"] = vname
+if vnum == 1:
+# the first version should always be an alias for the parent and
+# should therefore have no extra properties
+if version.items():
+raise RuntimeError("Unexpected properties in version 1")
+yield result
+continue
+
+# prefer the 'alias' over the generated the name if it exists since we
+# have already been using these aliases
+alias = version.pop(".alias", None)
+if alias:
+result["name"] = alias
+else:
+result["name"] = vname
 
 props = version.pop(".props", dict())
 for k, v in props:
@@ -377,6 +401,8 @@ def output_model(f, model):
 
 f.write("\n")
 f.write("  \n".format(model["name"]))
+if "canonical_name" in model and model["name"] != model["canonical_name"]:
+f.write("
{}\n".format(model["canonical_name"]))
 f.write("\n")
 f.write("\n".format(
 model["family"], model["model"]))
-- 
2.41.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvir

Re: [libvirt PATCH 0/5] add loongarch support for libvirt

2023-12-15 Thread Andrea Bolognani
On Thu, Dec 14, 2023 at 02:08:44PM +0800, xianglai li wrote:
> Hello, Everyone:
>   This patch series adds libvirt support for loongarch.Although the bios
> path and name has not been officially integrated into qemu and we think
> there are still many shortcomings, we try to push a version of patch to
> the community according to the opinions of the community, hoping to
> listen to everyone's opinions.

Sharing your work earlier rather than later is definitely a good
approach when it comes to open source development, so I appreciate
you doing this :)

>   loongarch's virtual machine bios is not yet available in qemu, so you can 
> get it from the following link
> https://github.com/loongson/Firmware/tree/main/LoongArchVirtMachine

Great to see that edk2 support has already been mainlined! An
excellent next step would be to get an edk2-loongarch64 package into
the various distros... Please consider working with the maintainers
for edk2 in Fedora to make that happen, as it would significantly
lower the barrier for interested people to get involved.

> (Note: You should clone the repository using git instead of downloading the 
> file via wget or you'll get xml)
> We named the bios edk2-loongarch64-code.fd, edk2-loongarch64-vars.fd is used 
> to store pflash images of non-volatile
> variables.After installing qemu-system-loongarch64, you need to manually copy 
> these two files to the /user/share/qemu
> directory.

As I have implicitly pointed out in the comment to one of the
patches, these paths are not correct.

The /usr/share/qemu/ directory is owned by the QEMU package, and
other components should not drop their files in there. The exception
is the /usr/share/qemu/firmware/ directory, which is specifically
designed for interoperation.

The edk2 files should be installed to /usr/share/edk2/loongarch64/,
following the convention established by existing architectures. Once
the directory name already contains architecture information, you can
use shorter and less unique names for the files themselves.

>   Well, if you have completed the above steps I think you can now install 
> loongarch virtual machine,
> you can install it through the virt-manager graphical interface, or install 
> it through vrit-install,
> here is an example of installing it using virt-install:
>
> virt-install  \
> --virt-type=qemu \
> --name  loongarch-test \
> --memory 4096 \
> --vcpus=4 \
> --arch=loongarch64 \
> --boot cdrom \
> --disk device=cdrom,bus=scsi,path=/root/livecd-fedora-mate-4.loongarch64.iso \
> --disk 
> path=/var/lib/libvirt/images/debian12-loongarch64.qcow2,size=10,format=qcow2,bus=scsi
>  \
> --network network=default \
> --osinfo archlinux   \
> --feature acpi=true \

This looks a bit out of place: virt-install should automatically
enable the ACPI feature if it's advertised as available by libvirt.

Please take a look at virQEMUCapsInitGuestFromBinary() and consider
updating it so that ACPI support for loongarch is advertised.

> lixianglai (5):
>   Add loongarch cpu support
>   Add loongarch cpu model and vendor info
>   Config some capabilities for loongarch virt machine
>   Implement the method of getting host info for loongarch
>   Add bios path for loongarch

The information provided in the cover letter, including pointers to
the various not-yet-upstreamed changes and instructions on how to
test everything, is very much appreciated!

Unfortunately I didn't have enough time to take things for a spin, so
I've limited myself to a relatively quick review.

In addition to the comments that I've provided for the code that is
there, I need to point out what is *not* there: specifically, any
kind of test :)

Before this can be considered for inclusion, we need to have some
test coverage. It doesn't have to be incredibly exhaustive, but at
least the basics need to be addressed. If you look for files that
contain "riscv64" in their names in the tests/ directory you should
get a decent idea of what kind of coverage we will need.

That's all I have for now. I'll talk to you again in 2024 :)

-- 
Andrea Bolognani / Red Hat / Virtualization
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 1/2] ci: integration: Switch upstream integration tests to Fedora 39

2023-12-15 Thread Andrea Bolognani
On Fri, Dec 15, 2023 at 06:06:54PM +0100, Erik Skultety wrote:
> On Fri, Dec 15, 2023 at 02:26:11AM -0800, Andrea Bolognani wrote:
> > On Thu, Dec 14, 2023 at 09:28:16AM +0100, Michal Privoznik wrote:
> > > Currently, Fedora 37 and 38 is used. The former is now EOL since
> > > there's new release. Switch 37 to 39 then.
> > >
> > > Signed-off-by: Michal Privoznik 
> > > ---
> > >  ci/integration.yml | 80 +++---
> > >  1 file changed, 40 insertions(+), 40 deletions(-)
> >
> > Patch looks good, but I don't think we can push it until the Fedora
> > 39 runner used for integration tests has been created, and AFAIK
> > that's a manual process.
> >
> > Erik, I know that you've taken care of this so far. Has the process
> > been documented anywhere? Is it something that people other than you
> > can deal with?
>
> Uhm, yes, it is documented, however that docs resource isn't public as it 
> runs on a private infra.
> Yes, Cleber and Jan should be able to do that too as they have access. I'd do 
> that for you myself
> no problem, but I'm already on PTO since today. If this isn't a blocker for 
> you until the new year,
> then I'll take care of it then.

I don't think it's a blocker.

And it's fine if the documentation is internal, as long as there's
more than one person that can push things forward when needed.

-- 
Andrea Bolognani / Red Hat / Virtualization
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [libvirt PATCH 5/5] Add bios path for loongarch

2023-12-15 Thread Andrea Bolognani
On Thu, Dec 14, 2023 at 02:08:49PM +0800, xianglai li wrote:
> +++ b/src/qemu/qemu_conf.c
> @@ -93,7 +93,8 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig);
>  "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
>  "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
>  "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd:" \
> -"/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd"
> +"/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd:" \
> +
> "/usr/share/qemu/edk2-loongarch64-code.fd:/usr/share/qemu/edk2-loongarch64-vars.fd"
>  #endif

We definitely don't want this :)

The hard-coded CODE:VARS pairs are considered a legacy mechanism at
this point, and we're no longer adding to them. If you try to pass a
custom value at build time, a warning will be raised.

The way firmware is configured these days is through firmware
descriptor files. See src/qemu/qemu_firmware* and tests/qemufirmware*
for additional information, but the short version is that you want
your edk2 package to include something like this:

  # /usr/share/qemu/firmware/50-edk2-loongarch64.json
  {
"interface-types": [
  "uefi"
],
"mapping": {
  "device": "flash",
  "mode" : "split",
  "executable": {
"filename": "/usr/share/edk2/loongarch64/QEMU_CODE.fd",
"format": "raw"
  },
  "nvram-template": {
"filename": "/usr/share/edk2/loongarch64/QEMU_VARS.fd",
"format": "raw"
  }
},
"targets": [
  {
"architecture": "loongarch64",
"machines": [
  "virt",
  "virt-*"
]
  }
]
  }

Once you have that, libvirt will automatically pick up the correct
firmware when the VM is configured with

  

Same as any other architecture, no custom entries needed.

-- 
Andrea Bolognani / Red Hat / Virtualization
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [libvirt PATCH 4/5] Implement the method of getting host info for loongarch

2023-12-15 Thread Andrea Bolognani
On Thu, Dec 14, 2023 at 02:08:48PM +0800, xianglai li wrote:
> +++ b/src/util/virhostcpu.c
> @@ -579,7 +579,7 @@ virHostCPUParsePhysAddrSize(FILE *cpuinfo, unsigned int 
> *addrsz)
>  char *str;
>  char *endptr;
>
> -if (!(str = STRSKIP(line, "address sizes")))
> +if (!(str = STRCASESKIP(line, "address sizes")))
>  continue;

So is the case different on loongarch than it is on other
architectures? Weird.

> +++ b/src/util/virsysinfo.c
> @@ -1241,14 +1241,15 @@ virSysinfoRead(void)
>  {
>  #if defined(__powerpc__)
>  return virSysinfoReadPPC();
> -#elif defined(__arm__) || defined(__aarch64__)
> +#elif defined(__arm__) || defined(__aarch64__) || defined(__loongarch__)
>  return virSysinfoReadARM();

This is definitely not right: we shouldn't be calling the
Arm-specific function on loongarch.

>  #elif defined(__s390__) || defined(__s390x__)
>  return virSysinfoReadS390();
>  #elif !defined(WIN32) && \
>  (defined(__x86_64__) || \
>   defined(__i386__) || \
> - defined(__amd64__))
> + defined(__amd64__) || \
> +defined(__loongarch__))
>  return virSysinfoReadDMI();

Does loongarch actually have DMI support?

-- 
Andrea Bolognani / Red Hat / Virtualization
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [libvirt PATCH 3/5] Config some capabilities for loongarch virt machine

2023-12-15 Thread Andrea Bolognani
On Thu, Dec 14, 2023 at 02:08:47PM +0800, xianglai li wrote:
> +++ b/src/qemu/qemu_domain.c
> @@ -5635,6 +5635,11 @@ 
> qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
>  cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
>  else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
>  cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
> +} else if (ARCH_IS_LOONGARCH(def->os.arch)) {
> +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
> +cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
> +else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
> +cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
>  }

I don't think you need to take into account the nec-xhci model for
loongarch. aarch64 needs it because qemu-xhci didn't exist when that
architecture was introduced, but that's not the case here so we can
keep things simpler.

I'm surprised that this code doesn't have handling for riscv64. Not
your problem, but likely an oversight that should be addressed.

> +static bool
> +qemuDomainMachineIsLoongson(const char *machine,
> +const virArch arch)

The appropriate name for this function would be
qemuDomainMachineIsLoongArchVirt, to match the existing Arm and
RISC-V equivalents.

> +bool
> +qemuDomainIsLoongson(const virDomainDef *def)
> +{

Same here.

> +++ b/src/qemu/qemu_domain_address.c
> @@ -2093,6 +2143,11 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDef 
> *def,
>  return -1;
>  }
>
> +if (qemuDomainIsLoongson(def) &&
> +qemuDomainValidateDevicePCISlotsLoongson(def, addrs) < 0) {
> +return -1;
> +}

The existing qemuDomainValidateDevicePCISlots* functions are intended
to ensure that certain devices, that historically have been assigned
to specific PCI slots by QEMU, always show up at those addresses.

We haven't needed anything like that for non-x86 architectures so
far, and I believe that loongarch doesn't need it either.

> +++ b/src/qemu/qemu_validate.c
> @@ -100,7 +100,7 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
>  switch ((virDomainFeature) i) {
>  case VIR_DOMAIN_FEATURE_IOAPIC:
>  if (def->features[i] != VIR_DOMAIN_IOAPIC_NONE) {
> -if (!ARCH_IS_X86(def->os.arch)) {
> +if (!ARCH_IS_X86(def->os.arch) && 
> !ARCH_IS_LOONGARCH(def->os.arch)) {
>  virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> _("The '%1$s' feature is not supported 
> for architecture '%2$s' or machine type '%3$s'"),
> featureName,

So does loongarch actually have ioapic support? Just making sure. I'm
surprised because apparently no other non-x86 architecture supports
it...

-- 
Andrea Bolognani / Red Hat / Virtualization
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [libvirt PATCH 1/5] Add loongarch cpu support

2023-12-15 Thread Andrea Bolognani
On Thu, Dec 14, 2023 at 02:08:45PM +0800, xianglai li wrote:
> From: lixianglai 
>
> Add loongarch cpu support, Define new cpu type 'loongarch64'
> and implement it's driver functions.
>
> Signed-off-by: lixianglai 

We usually prefer the full name to be used both for git authorship
and DCO purposes. I believe this would be "Xianglai Li" in your case.

> ---
>  po/POTFILES |   1 +
>  src/conf/schemas/basictypes.rng |   1 +
>  src/cpu/cpu.c   |   2 +
>  src/cpu/cpu.h   |   2 +
>  src/cpu/cpu_loongarch.c | 742 
>  src/cpu/cpu_loongarch.h |  25 ++
>  src/cpu/cpu_loongarch_data.h|  37 ++
>  src/cpu/meson.build |   1 +
>  src/qemu/qemu_capabilities.c|   1 +
>  src/qemu/qemu_domain.c  |   4 +
>  src/util/virarch.c  |   2 +
>  src/util/virarch.h  |   4 +
>  12 files changed, 822 insertions(+)
>  create mode 100644 src/cpu/cpu_loongarch.c
>  create mode 100644 src/cpu/cpu_loongarch.h
>  create mode 100644 src/cpu/cpu_loongarch_data.h

This patch breaks the test suite:

  $ make -C .../libvirt/build/build-aux sc_preprocessor_indentation
  make: Entering directory '.../libvirt/build/build-aux'
  cppi: .../libvirt/src/cpu/cpu_loongarch.h: line 23: not properly indented
  cppi: .../libvirt/src/cpu/cpu_loongarch_data.h: line 23: not properly indented
  cppi: .../libvirt/src/cpu/cpu_loongarch_data.h: line 31: not properly indented
  incorrect preprocessor indentation
  make: *** [.../libvirt/build-aux/syntax-check.mk:500:
sc_preprocessor_indentation] Error 1
  make: Leaving directory '.../libvirt/build/build-aux'

Should be an easy enough fix.

Please make sure that 'meson test' runs successfully after every
single patch in the series, and that you have optional test tools
such as cppi installed.

> +++ b/src/conf/schemas/basictypes.rng
> @@ -470,6 +470,7 @@
>x86_64
>xtensa
>xtensaeb
> +  loongarch64

This list is sorted alphabetically; please ensure that it remains
that way after your changes. Not all lists in libvirt are sorted
alphabetically, but generally speaking if you see one that is you
should keep it that way.

> +++ b/src/cpu/cpu_loongarch.c
> @@ -0,0 +1,742 @@
> +static const virArch archs[] = { VIR_ARCH_LOONGARCH64 };
> +
> +typedef struct _virCPULoongArchVendor virCPULoongArchVendor;
> +struct _virCPULoongArchVendor {
> +char *name;
> +};
> +
> +typedef struct _virCPULoongArchModel virCPULoongArchModel;
> +struct _virCPULoongArchModel {
> +char *name;
> +const virCPULoongArchVendor *vendor;
> +virCPULoongArchData data;
> +};
> +
> +typedef struct _virCPULoongArchMap virCPULoongArchMap;
> +struct _virCPULoongArchMap {
> +size_t nvendors;
> +virCPULoongArchVendor **vendors;
> +size_t nmodels;
> +virCPULoongArchModel **models;
> +};

This CPU driver appears to be directly modeled after the ppc64
driver. I wonder if all the complexity is necessary at this point in
time? Wouldn't it perhaps be better to start with a very bare-bone
CPU driver, modeled after the riscv64 one, and then grow from there
as the demand for more advanced features becomes apparent?

> +static int
> +virCPULoongArchGetHostPRID(void)
> +{
> +return 0x14c010;
> +}

Hardcoding the host CPU's PRID...

> +static int
> +virCPULoongArchGetHost(virCPUDef *cpu,
> +   virDomainCapsCPUModels *models)
> +{
> +virCPUData *cpuData = NULL;
> +virCPULoongArchData *data;
> +int ret = -1;
> +
> +if (!(cpuData = virCPUDataNew(archs[0])))
> +goto cleanup;
> +
> +data = &cpuData->data.loongarch;
> +data->prid = g_new0(virCPULoongArchPrid, 1);
> +if (!data->prid)
> +goto cleanup;
> +
> +
> +data->len = 1;
> +
> +data->prid[0].value = virCPULoongArchGetHostPRID();
> +data->prid[0].mask = 0x00ul;

... and corresponding mask is definitely not acceptable. You'll need
to implement a function that fetches the value dynamically by using
whatever mechanism is appropriate, and of course ensure that such
code is only ever run on a loongarch64 host.

But again, do we really need that complexity right now? The riscv64
driver doesn't have any of that and is usable for many purposes.

> +static virCPUDef *
> +virCPULoongArchDriverBaseline(virCPUDef **cpus,
> +unsigned int ncpus,
> +virDomainCapsCPUModels *models ATTRIBUTE_UNUSED,
> +const char **features ATTRIBUTE_UNUSED,
> +bool migratable ATTRIBUTE_UNUSED)

The function arguments are not aligned properly here. There are
several other instances of this. Please make sure that things are
aligned correctly throughout.

> diff --git a/src/cpu/meson.build b/src/cpu/meson.build
> index 55396903b9..254d6b4545 100644
> --- a/src/cpu/meson.build
> +++ b/src/cpu/meson.build
> @@ -6,6 +6,7 @@ cpu_sources = [
>'cpu_riscv64.c',
>'cpu_s390.c',
>

Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Denis V. Lunev

On 12/15/23 16:07, Daniel P. Berrangé wrote:

On Fri, Dec 15, 2023 at 01:48:09PM +, Efim Shevrin wrote:

Hello,

here are call traces with two threads generated by python script
// ==
[root@dandreev-vz-6-0-0-243-master libvirt]# gdb -p 288985
(gdb) t a a bt

Thread 2 (Thread 0x7f2112862640 (LWP 288986) "python3"):
#0  0x7f2121d4296f in poll () at /lib64/libc.so.6
#1  0x7f211444650c in g_main_context_iterate.constprop () at 
/lib64/libglib-2.0.so.0
#2  0x7f21143f1483 in g_main_loop_run () at /lib64/libglib-2.0.so.0
#3  0x7f211406800b in virNetClientIOEventLoop () at /lib64/libvirt.so.0
#4  0x7f2114068a0a in virNetClientIO () at /lib64/libvirt.so.0
#5  0x7f21140692c1 in virNetClientSendInternal () at /lib64/libvirt.so.0
#6  0x7f211406936d in virNetClientSendWithReply () at /lib64/libvirt.so.0
#7  0x7f2114061a1d in virNetClientProgramCall () at /lib64/libvirt.so.0
#8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
#9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
#10 0x7f21140d8435 in remoteDomainCreate () at /lib64/libvirt.so.0
#11 0x7f21141dd60c in virDomainCreate () at /lib64/libvirt.so.0
#12 0x7f21145c8114 in libvirt_virDomainCreate () at 
/usr/lib64/python3.9/site-packages/libvirtmod.cpython-39-x86_64-linux-gnu.so

Ok, this thread is the primary one responsible for I/O. It is
waiting, while not holding any mutex.

Correct.





Thread 1 (Thread 0x7f21223cf740 (LWP 288985) "python3"):
#0  0x7f2121c9c39a in __futex_abstimed_wait_common () at /lib64/libc.so.6
#1  0x7f2121c9eba0 in pthread_cond_wait@@GLIBC_2.3.2 () at /lib64/libc.so.6
#2  0x7f2113f4982a in virCondWait () at /lib64/libvirt.so.0
#3  0x7f2113f1fee3 in virObjectWait () at /lib64/libvirt.so.0
#4  0x7f211406882a in virNetClientIO () at /lib64/libvirt.so.0
#5  0x7f21140692c1 in virNetClientSendInternal () at /lib64/libvirt.so.0
#6  0x7f211406936d in virNetClientSendWithReply () at /lib64/libvirt.so.0
#7  0x7f2114061a1d in virNetClientProgramCall () at /lib64/libvirt.so.0
#8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
#9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
#10 0x7f21140f24eb in remoteNodeDeviceNumOfCaps () at /lib64/libvirt.so.0
#11 0x7f2114207a00 in virNodeDeviceNumOfCaps () at /lib64/libvirt.so.0

This is a second API call that has arrived and has queued its outgoing
message, and is waiting either for the other thread to pass ownership
of the socket to it, or for the other thread to provide its reply (whichever
comes first).


This is all totally normal, and working as expected, so I still
don't see what the actual problem is ?

No. This is not normal.

The test is written in the following way.
1. One thread (2) has started very long operation, f.e. VM migration
2. Another thread (1) endlessly executes simple fast requests.
   Normally these requests are executed fast and we see progress
   in the log. Though there is a probability that thread (1)
   stuck until request processed by thread (2) is not completed.
3. It should be noted that this is not a final "deadlock" as
   once thread (2) completes its request, the process in thread (1)
   is restarted normally.

Such behavior is a real pain. It has been detected by us once
OpenStack Nova (which is working in this way) has been reported
as unavailable.

We have traced down this problem and comes to the conclusion
that in the case of such behavior the problem is missed
wakeup. In the debugger, if I call g_mail_loop_quit()
thread (1) in unfrozen and requests are started processed
normally.

We have observed this problem over libvirt 8.5 and compared
the behavior indeed against ancient libvirt 5.6. The ancient
one does *NOT* have this problem and thus the problem is
looking like a degradation.

The difference in between them is a wakeup method. In
libvirt 5.6 thread (2) is sleeping in a poll() and is
woken up by writing to the pipe. Thus the sequence
like called from the same thread (for simplicity)
  wakeup()
  waiting()
behaves differently in libvirt 5.6 and libvirt 8.5
and this causes this trouble.


// =

just in case here is python script

[root@dandreev-vz-6-0-0-243-master ~]# cat a.py
import libvirt
import time
from threading import Thread

def startVM(connection, vm_name):
 try:
 # Find the virtual machine by name
 print('starting VM')
 connection.lookupByName(vm_name).create()
 print('done starting VM')
 except libvirt.libvirtError as e:
 print(f'Libvirt Error: {e}')

# Replace 'qemu+tcp://10.34.66.13/system' with your actual connection URI
connection_uri = 'qemu+tcp://localhost/system'
connection = libvirt.open(connection_uri)
if connection is None:
 print(f'Failed to open connection to {connection_uri}')
 exit(1)

try:
 # Replace 'your_vm_name' with the actual name of your virtual machine
 # 

Re: [PATCH 1/2] ci: integration: Switch upstream integration tests to Fedora 39

2023-12-15 Thread Erik Skultety
On Fri, Dec 15, 2023 at 02:26:11AM -0800, Andrea Bolognani wrote:
> On Thu, Dec 14, 2023 at 09:28:16AM +0100, Michal Privoznik wrote:
> > Currently, Fedora 37 and 38 is used. The former is now EOL since
> > there's new release. Switch 37 to 39 then.
> >
> > Signed-off-by: Michal Privoznik 
> > ---
> >  ci/integration.yml | 80 +++---
> >  1 file changed, 40 insertions(+), 40 deletions(-)
> 
> Patch looks good, but I don't think we can push it until the Fedora
> 39 runner used for integration tests has been created, and AFAIK
> that's a manual process.
> 
> Erik, I know that you've taken care of this so far. Has the process
> been documented anywhere? Is it something that people other than you
> can deal with?

Uhm, yes, it is documented, however that docs resource isn't public as it runs 
on a private infra.
Yes, Cleber and Jan should be able to do that too as they have access. I'd do 
that for you myself
no problem, but I'm already on PTO since today. If this isn't a blocker for you 
until the new year,
then I'll take care of it then.

Erik
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Denis V. Lunev

On 12/15/23 16:47, Daniel P. Berrangé wrote:

On Fri, Dec 15, 2023 at 03:51:19PM +0100, Denis V. Lunev wrote:

On 12/15/23 14:48, Efim Shevrin wrote:

*From:* Daniel P. Berrangé 
*Sent:* Friday, December 15, 2023 19:09
*To:* Efim Shevrin 
*Cc:* devel@lists.libvirt.org ; d...@openvz.org

*Subject:* Re: [PATCH 3/3] rpc: Rework rpc notifications in main and
side thread
[You don't often get email from berra...@redhat.com. Learn why this is
important at https://aka.ms/LearnAboutSenderIdentification ]

On Fri, Dec 15, 2023 at 02:32:19AM +0800, Fima Shevrin wrote:

RPC client implementation uses the following paradigm. The critical
section is organized via virObjectLock(client)/virObjectUnlock(client)
braces. Though this is potentially problematic as
  main thread:    side thread:
  virObjectUnlock(client);
virObjectLock(client);
g_main_loop_quit(client->eventLoop);
virObjectUnlock(client);
  g_main_loop_run(client->eventLoop);

This means in particular that is the main thread is executing very long
request like VM migration, the wakeup from the side thread could be
stuck until the main request will be fully completed.

Can you explain this in more detail, with call traces illustration
for the two threads. You're not saying where the main thread is
doing work with the 'client' lock hold for a long time. Generally
the goal should be for the main thread to only hold the lock for
a short time.  Also if the side thread is already holding a reference
on 'client', then potentially we should consider if it is possible
to terminate the event loop without acquiring the mutex, as GMainLoop
protects itself wrt concurrent usage already, provided all threads
hold a reference directly or indirectly.

At our opinion the problem here is missed wakeup from
the side thread to the main thread.

Hmmm, what platform are you seeing problems on ? Are you still targetting
a very old RHEL-7 platform ?  I vaguely recall there are/weere some old
glib bugs in the main loop with threads that could be applicable.

With regards,
Daniel

Nope. Original problem is observed against RHEL 9.1 i.e. libvirt 8.5.
But the problem here comes from the "comparison" with very old
ancient libvirt 5.6 which behaves here MUCH better.

Den
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 04/19] qemuxml2argvdata: Move 'smbios-multiple-type2' case to genericxml2xmltest

2023-12-15 Thread Peter Krempa
On Fri, Dec 15, 2023 at 13:33:14 +0100, Peter Krempa wrote:
> The qemu driver explicitly rejects such configuration, thus this is just
> a generic XML2XML test case. Move it.
> 
> Signed-off-by: Peter Krempa 
> ---
>  .../smbios-multiple-type2.xml   | 0
>  tests/genericxml2xmltest.c  | 2 ++
>  tests/qemuxml2xmltest.c | 1 -
>  3 files changed, 2 insertions(+), 1 deletion(-)
>  rename tests/{qemuxml2argvdata => 
> genericxml2xmlindata}/smbios-multiple-type2.xml (100%)

Also tests/qemuxml2xmloutdata/smbios-multiple-type2.xml needs to be
removed. I've squashed that change in locally.
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Daniel P . Berrangé
On Fri, Dec 15, 2023 at 03:51:19PM +0100, Denis V. Lunev wrote:
> On 12/15/23 14:48, Efim Shevrin wrote:
> > *From:* Daniel P. Berrangé 
> > *Sent:* Friday, December 15, 2023 19:09
> > *To:* Efim Shevrin 
> > *Cc:* devel@lists.libvirt.org ; d...@openvz.org
> > 
> > *Subject:* Re: [PATCH 3/3] rpc: Rework rpc notifications in main and
> > side thread
> > [You don't often get email from berra...@redhat.com. Learn why this is
> > important at https://aka.ms/LearnAboutSenderIdentification ]
> > 
> > On Fri, Dec 15, 2023 at 02:32:19AM +0800, Fima Shevrin wrote:
> > > RPC client implementation uses the following paradigm. The critical
> > > section is organized via virObjectLock(client)/virObjectUnlock(client)
> > > braces. Though this is potentially problematic as
> > > main thread:    side thread:
> > > virObjectUnlock(client);
> > > virObjectLock(client);
> > > g_main_loop_quit(client->eventLoop);
> > > virObjectUnlock(client);
> > > g_main_loop_run(client->eventLoop);
> > >
> > > This means in particular that is the main thread is executing very long
> > > request like VM migration, the wakeup from the side thread could be
> > > stuck until the main request will be fully completed.
> > 
> > Can you explain this in more detail, with call traces illustration
> > for the two threads. You're not saying where the main thread is
> > doing work with the 'client' lock hold for a long time. Generally
> > the goal should be for the main thread to only hold the lock for
> > a short time.  Also if the side thread is already holding a reference
> > on 'client', then potentially we should consider if it is possible
> > to terminate the event loop without acquiring the mutex, as GMainLoop
> > protects itself wrt concurrent usage already, provided all threads
> > hold a reference directly or indirectly.
> 
> At our opinion the problem here is missed wakeup from
> the side thread to the main thread.

Hmmm, what platform are you seeing problems on ? Are you still targetting
a very old RHEL-7 platform ?  I vaguely recall there are/weere some old
glib bugs in the main loop with threads that could be applicable.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Daniel P . Berrangé
On Fri, Dec 15, 2023 at 01:48:09PM +, Efim Shevrin wrote:
> Hello,
> 
> here are call traces with two threads generated by python script
> // ==
> [root@dandreev-vz-6-0-0-243-master libvirt]# gdb -p 288985
> (gdb) t a a bt
> 
> Thread 2 (Thread 0x7f2112862640 (LWP 288986) "python3"):
> #0  0x7f2121d4296f in poll () at /lib64/libc.so.6
> #1  0x7f211444650c in g_main_context_iterate.constprop () at 
> /lib64/libglib-2.0.so.0
> #2  0x7f21143f1483 in g_main_loop_run () at /lib64/libglib-2.0.so.0
> #3  0x7f211406800b in virNetClientIOEventLoop () at /lib64/libvirt.so.0
> #4  0x7f2114068a0a in virNetClientIO () at /lib64/libvirt.so.0
> #5  0x7f21140692c1 in virNetClientSendInternal () at /lib64/libvirt.so.0
> #6  0x7f211406936d in virNetClientSendWithReply () at /lib64/libvirt.so.0
> #7  0x7f2114061a1d in virNetClientProgramCall () at /lib64/libvirt.so.0
> #8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
> #9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
> #10 0x7f21140d8435 in remoteDomainCreate () at /lib64/libvirt.so.0
> #11 0x7f21141dd60c in virDomainCreate () at /lib64/libvirt.so.0
> #12 0x7f21145c8114 in libvirt_virDomainCreate () at 
> /usr/lib64/python3.9/site-packages/libvirtmod.cpython-39-x86_64-linux-gnu.so

Ok, this thread is the primary one responsible for I/O. It is
waiting, while not holding any mutex.

> Thread 1 (Thread 0x7f21223cf740 (LWP 288985) "python3"):
> #0  0x7f2121c9c39a in __futex_abstimed_wait_common () at /lib64/libc.so.6
> #1  0x7f2121c9eba0 in pthread_cond_wait@@GLIBC_2.3.2 () at 
> /lib64/libc.so.6
> #2  0x7f2113f4982a in virCondWait () at /lib64/libvirt.so.0
> #3  0x7f2113f1fee3 in virObjectWait () at /lib64/libvirt.so.0
> #4  0x7f211406882a in virNetClientIO () at /lib64/libvirt.so.0
> #5  0x7f21140692c1 in virNetClientSendInternal () at /lib64/libvirt.so.0
> #6  0x7f211406936d in virNetClientSendWithReply () at /lib64/libvirt.so.0
> #7  0x7f2114061a1d in virNetClientProgramCall () at /lib64/libvirt.so.0
> #8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
> #9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
> #10 0x7f21140f24eb in remoteNodeDeviceNumOfCaps () at /lib64/libvirt.so.0
> #11 0x7f2114207a00 in virNodeDeviceNumOfCaps () at /lib64/libvirt.so.0

This is a second API call that has arrived and has queued its outgoing
message, and is waiting either for the other thread to pass ownership
of the socket to it, or for the other thread to provide its reply (whichever
comes first).


This is all totally normal, and working as expected, so I still
don't see what the actual problem is ?

> // =
> 
> just in case here is python script
> 
> [root@dandreev-vz-6-0-0-243-master ~]# cat a.py
> import libvirt
> import time
> from threading import Thread
> 
> def startVM(connection, vm_name):
> try:
> # Find the virtual machine by name
> print('starting VM')
> connection.lookupByName(vm_name).create()
> print('done starting VM')
> except libvirt.libvirtError as e:
> print(f'Libvirt Error: {e}')
> 
> # Replace 'qemu+tcp://10.34.66.13/system' with your actual connection URI
> connection_uri = 'qemu+tcp://localhost/system'
> connection = libvirt.open(connection_uri)
> if connection is None:
> print(f'Failed to open connection to {connection_uri}')
> exit(1)
> 
> try:
> # Replace 'your_vm_name' with the actual name of your virtual machine
> # startVM(connection, 'instance-0002')
> thread = Thread(target=lambda: startVM(connection, 'instance-0002'))
> thread.start()
> time.sleep(3)
> devs = connection.listAllDevices()
> for i in range(10):
> for dev in devs:
> print('listing caps for dev %i %s' % (i, dev))
> try:
> dev.listCaps()
> except Exception as e:
> print('ERROR: %s' % e)
> print('DONE listing caps')
> 
> connection.lookupByName('instance-0002').destroy()
> except:
> connection.lookupByName('instance-0002').destroy()
> finally:
> thread.join()
> # Close the connection outside the function
> connection.close()

What behaviour are you expecting this demo program to show ?

When I run it, the VM starts and the the dev caps listing is
then run 3 seconds later (due to the sleep).  Removing the
sleep, I can see the caps list running in parallel with the
'create'.

Basically I see nothing wrong.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an 

Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Denis V. Lunev

On 12/15/23 14:48, Efim Shevrin wrote:

Hello,

here are call traces with two threads generated by python script
// ==
[root@dandreev-vz-6-0-0-243-master libvirt]# gdb -p 288985
(gdb) t a a bt

Thread 2 (Thread 0x7f2112862640 (LWP 288986) "python3"):
#0  0x7f2121d4296f in poll () at /lib64/libc.so.6
#1  0x7f211444650c in g_main_context_iterate.constprop () at 
/lib64/libglib-2.0.so.0

#2  0x7f21143f1483 in g_main_loop_run () at /lib64/libglib-2.0.so.0
#3  0x7f211406800b in virNetClientIOEventLoop () at 
/lib64/libvirt.so.0

#4  0x7f2114068a0a in virNetClientIO () at /lib64/libvirt.so.0
#5  0x7f21140692c1 in virNetClientSendInternal () at 
/lib64/libvirt.so.0
#6  0x7f211406936d in virNetClientSendWithReply () at 
/lib64/libvirt.so.0
#7  0x7f2114061a1d in virNetClientProgramCall () at 
/lib64/libvirt.so.0

#8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
#9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
#10 0x7f21140d8435 in remoteDomainCreate () at /lib64/libvirt.so.0
#11 0x7f21141dd60c in virDomainCreate () at /lib64/libvirt.so.0
#12 0x7f21145c8114 in libvirt_virDomainCreate () at 
/usr/lib64/python3.9/site-packages/libvirtmod.cpython-39-x86_64-linux-gnu.so

#13 0x7f21221268a8 in cfunction_call () at /lib64/libpython3.9.so.1.0
#14 0x7f2122118814 in _PyObject_MakeTpCall () at 
/lib64/libpython3.9.so.1.0
#15 0x7f212211566e in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#16 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#17 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#18 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#19 0x7f21221103e8 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#20 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#21 0x7f21221133d2 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#22 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#23 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#24 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#25 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#26 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#27 0x7f2122125382 in method_vectorcall () at 
/lib64/libpython3.9.so.1.0

#28 0x7f21221d8c4a in t_bootstrap () at /lib64/libpython3.9.so.1.0
#29 0x7f21221d8bf8 in pythread_wrapper () at 
/lib64/libpython3.9.so.1.0

#30 0x7f2121c9f802 in start_thread () at /lib64/libc.so.6
#31 0x7f2121c3f450 in clone3 () at /lib64/libc.so.6

Thread 1 (Thread 0x7f21223cf740 (LWP 288985) "python3"):
#0  0x7f2121c9c39a in __futex_abstimed_wait_common () at 
/lib64/libc.so.6
#1  0x7f2121c9eba0 in pthread_cond_wait@@GLIBC_2.3.2 () at 
/lib64/libc.so.6

#2  0x7f2113f4982a in virCondWait () at /lib64/libvirt.so.0
#3  0x7f2113f1fee3 in virObjectWait () at /lib64/libvirt.so.0
#4  0x7f211406882a in virNetClientIO () at /lib64/libvirt.so.0
#5  0x7f21140692c1 in virNetClientSendInternal () at 
/lib64/libvirt.so.0
#6  0x7f211406936d in virNetClientSendWithReply () at 
/lib64/libvirt.so.0
#7  0x7f2114061a1d in virNetClientProgramCall () at 
/lib64/libvirt.so.0

#8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
#9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
#10 0x7f21140f24eb in remoteNodeDeviceNumOfCaps () at 
/lib64/libvirt.so.0

#11 0x7f2114207a00 in virNodeDeviceNumOfCaps () at /lib64/libvirt.so.0
#12 0x7f21145d8edf in libvirt_virNodeDeviceListCaps.lto_priv.0 () 
at 
/usr/lib64/python3.9/site-packages/libvirtmod.cpython-39-x86_64-linux-gnu.so

#13 0x7f21221268a8 in cfunction_call () at /lib64/libpython3.9.so.1.0
#14 0x7f2122118814 in _PyObject_MakeTpCall () at 
/lib64/libpython3.9.so.1.0
#15 0x7f212211566e in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#16 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#17 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#18 0x7f212210f06d in _PyEval_EvalCode () at 
/lib64/libpython3.9.so.1.0
#19 0x7f212218c495 in _PyEval_EvalCodeWithName () at 
/lib64/libpython3.9.so.1.0

--Type  for more, q to quit, c to continue without paging--
#20 0x7f212218c42d in PyEval_EvalCodeEx () at 
/lib64/libpython3.9.so.1.0

#21 0x7f212218c3df in PyEval_EvalCode () at /lib64/libpython3.9.so.1.0
#22 0x7f21221b7524 in run_eval_code_obj () at 
/lib64/libpython3.9.so.1.0

#23 0x7f21221b5da6 in run_mod () at /lib64/libpython3.9.so.1.0
#24 0x7f212208f0cb in pyrun_file.cold () at /lib64/libpython3.9.so.1.0
#25 0x7f21221bb253 in PyRun_SimpleFileExFlags () at 
/lib64/libpython3.9.so.1.0

#26 0x7f21221b7ee8 in Py_RunMain () at /lib64/lib

[PATCH 4/4] vmx: Ensure unique disk targets when parsing

2023-12-15 Thread Michal Privoznik
When parsing disks from a vmx file, the target name is generated
based on disk bus, controller the disk is attached to, and its
unit. But in case of SCSI and SATA attached disks this does not
guarantee the target name uniqueness. If there are two disks, one
attached to scsi.0 and the other to sata.0 both end up with the
same "sda" target name. And because of the way their drive
address is derived, they end up with the same address too.

Try harder to generate an unique disk target.

Signed-off-by: Michal Privoznik 
---
 src/vmx/vmx.c| 189 +--
 tests/vmx2xmldata/esx-in-the-wild-12.xml |   4 +-
 tests/vmx2xmldata/esx-in-the-wild-8.xml  |   4 +-
 3 files changed, 109 insertions(+), 88 deletions(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 399f03b419..7c752c72f9 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2142,105 +2142,126 @@ virXMXGenerateDiskTarget(virDomainDiskDef *def,
  int controllerOrBus,
  int unit)
 {
-const char *prefix = NULL;
-unsigned int idx = 0;
-
-switch (def->bus) {
-case VIR_DOMAIN_DISK_BUS_SCSI:
-if (controllerOrBus < 0 || controllerOrBus > 3) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("SCSI controller index %1$d out of [0..3] range"),
-   controllerOrBus);
-return -1;
-}
+unsigned int tries = 0;
 
-if (unit < 0 || unit > vmdef->scsiBusMaxUnit || unit == 7) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("SCSI unit index %1$d out of [0..6,8..%2$u] 
range"),
-   unit, vmdef->scsiBusMaxUnit);
-return -1;
-}
+for (tries = 0; tries < 10; tries++) {
+g_autofree char *dst = NULL;
+const char *prefix = NULL;
+unsigned int idx = 0;
+size_t i;
 
-idx = controllerOrBus * 15 + (unit < 7 ? unit : unit - 1);
-prefix = "sd";
-break;
+switch (def->bus) {
+case VIR_DOMAIN_DISK_BUS_SCSI:
+if (controllerOrBus < 0 || controllerOrBus > 3) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SCSI controller index %1$d out of [0..3] 
range"),
+   controllerOrBus);
+return -1;
+}
 
-case VIR_DOMAIN_DISK_BUS_SATA:
-if (controllerOrBus < 0 || controllerOrBus > 3) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("SATA controller index %1$d out of [0..3] range"),
-   controllerOrBus);
-return -1;
-}
+if (unit < 0 || unit > vmdef->scsiBusMaxUnit || unit == 7) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SCSI unit index %1$d out of [0..6,8..%2$u] 
range"),
+   unit, vmdef->scsiBusMaxUnit);
+return -1;
+}
 
-if (unit < 0 || unit >= 30) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("SATA unit index %1$d out of [0..29] range"),
-   unit);
-return -1;
-}
+idx = controllerOrBus * 15 + (unit < 7 ? unit : unit - 1);
+prefix = "sd";
+break;
 
-idx = controllerOrBus * 30 + unit;
-prefix = "sd";
-break;
+case VIR_DOMAIN_DISK_BUS_SATA:
+if (controllerOrBus < 0 || controllerOrBus > 3) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SATA controller index %1$d out of [0..3] 
range"),
+   controllerOrBus);
+return -1;
+}
 
-case VIR_DOMAIN_DISK_BUS_IDE:
-if (controllerOrBus < 0 || controllerOrBus > 1) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("IDE bus index %1$d out of [0..1] range"),
-   controllerOrBus);
-return -1;
-}
+if (unit < 0 || unit >= 30) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SATA unit index %1$d out of [0..29] range"),
+   unit);
+return -1;
+}
+
+idx = controllerOrBus * 30 + unit;
+prefix = "sd";
+break;
 
-if (unit < 0 || unit > 1) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("IDE unit index %1$d out of [0..1] range"), unit);
+case VIR_DOMAIN_DISK_BUS_IDE:
+if (controllerOrBus < 0 || controllerOrBus > 1) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("IDE bus index %1$d out of [0..1] range"),
+   controllerOrBus);
+return -1;
+}
+
+if (

[PATCH 2/4] vmx2xmltest: Add another test case

2023-12-15 Thread Michal Privoznik
Signed-off-by: Michal Privoznik 
---
 tests/vmx2xmldata/esx-in-the-wild-12.vmx | 86 
 tests/vmx2xmldata/esx-in-the-wild-12.xml | 39 +++
 tests/vmx2xmltest.c  |  1 +
 3 files changed, 126 insertions(+)
 create mode 100644 tests/vmx2xmldata/esx-in-the-wild-12.vmx
 create mode 100644 tests/vmx2xmldata/esx-in-the-wild-12.xml

diff --git a/tests/vmx2xmldata/esx-in-the-wild-12.vmx 
b/tests/vmx2xmldata/esx-in-the-wild-12.vmx
new file mode 100644
index 00..31963ffb12
--- /dev/null
+++ b/tests/vmx2xmldata/esx-in-the-wild-12.vmx
@@ -0,0 +1,86 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "20"
+vmci0.present = "TRUE"
+floppy0.present = "FALSE"
+svga.vramSize = "8388608"
+memSize = "2048"
+firmware = "efi"
+tools.upgrade.policy = "manual"
+sched.cpu.units = "mhz"
+vm.createDate = "1702444883756312"
+scsi0.virtualDev = "pvscsi"
+scsi0.present = "TRUE"
+sata0.present = "TRUE"
+sata0:0.startConnected = "FALSE"
+sata0:0.deviceType = "cdrom-image"
+sata0:0.fileName = ""
+sata0:0.present = "TRUE"
+scsi0:0.deviceType = "scsi-hardDisk"
+scsi0:0.fileName = "Auto-esx8.0-rhell9.3-efi-with-empty-cdrom.vmdk"
+sched.scsi0:0.shares = "normal"
+sched.scsi0:0.throughputCap = "off"
+scsi0:0.present = "TRUE"
+ethernet0.allowGuestConnectionControl = "FALSE"
+ethernet0.virtualDev = "vmxnet3"
+ethernet0.networkName = "VM Network"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:a0:cf:2f"
+ethernet0.uptCompatibility = "TRUE"
+ethernet0.present = "TRUE"
+displayName = "Auto-esx8.0-rhell9.3-efi-with-empty-cdrom"
+guestOS = "rhel9-64"
+chipset.motherboardLayout = "acpi"
+uefi.secureBoot.enabled = "TRUE"
+toolScripts.afterPowerOn = "TRUE"
+toolScripts.afterResume = "TRUE"
+toolScripts.beforeSuspend = "TRUE"
+toolScripts.beforePowerOff = "TRUE"
+tools.syncTime = "FALSE"
+tools.guest.desktop.autolock = "TRUE"
+uuid.bios = "42 20 fc a7 11 dd d6 7e-19 cc fc ad 0a 37 c3 42"
+vc.uuid = "50 20 ca 5b 7a c1 5c 44-cf a1 9e 76 2e 2f 93 3b"
+nvram = "Auto-esx8.0-rhell9.3-efi-with-empty-cdrom.nvram"
+svga.present = "TRUE"
+hpet0.present = "TRUE"
+RemoteDisplay.maxConnections = "-1"
+sched.cpu.latencySensitivity = "normal"
+numa.autosize.cookie = "10012"
+numa.autosize.vcpu.maxPerVirtualNode = "1"
+cpuid.coresPerSocket.cookie = "1"
+pciBridge1.present = "TRUE"
+pciBridge1.virtualDev = "pciRootBridge"
+pciBridge1.functions = "1"
+pciBridge1:0.pxm = "0"
+pciBridge0.present = "TRUE"
+pciBridge0.virtualDev = "pciRootBridge"
+pciBridge0.functions = "1"
+pciBridge0.pxm = "-1"
+scsi0.pciSlotNumber = "32"
+ethernet0.pciSlotNumber = "33"
+sata0.pciSlotNumber = "34"
+scsi0.sasWWID = "50 05 05 67 11 dd d6 70"
+vmotion.checkpointFBSize = "4194304"
+vmotion.checkpointSVGAPrimarySize = "8388608"
+vmotion.svga.mobMaxSize = "8388608"
+vmotion.svga.graphicsMemoryKB = "8192"
+monitor.phys_bits_used = "45"
+softPowerOff = "FALSE"
+tools.remindInstall = "TRUE"
+svga.guestBackedPrimaryAware = "TRUE"
+guestInfo.detailed.data = "architecture='X86' bitness='64' 
cpeString='cpe:/o:redhat:enterprise_linux:9::baseos' distroAddlVersion='9.3 
(Plow)' distroName='Red Hat Enterprise Linux' distroVersion='9.3' 
familyName='Linux' kernelVersion='5.14.0-362.8.1.el9_3.x86_64' prettyName='Red 
Hat Enterprise Linux 9.3 (Plow)'"
+vmxstats.filename = "esx8.0-rhel9.3-x86_64.scoreboard"
+migrate.hostLog = "Auto-esx8.0-rhell9.3-efi-with-empty-cdrom-3ea47ba9.hlog"
+sched.cpu.min = "0"
+sched.cpu.shares = "normal"
+sched.mem.min = "0"
+sched.mem.minSize = "0"
+sched.mem.shares = "normal"
+migrate.encryptionMode = "opportunistic"
+ftcpt.ftEncryptionMode = "ftEncryptionOpportunistic"
+viv.moid = 
"e00e5864-a7ed-4b49-b99a-71da911f679c:vm-1008:OCn73UgW4dBwF0sgk/5SmLb24snLgdgGTDWbdB/O5g4="
+sched.swap.derivedName = 
"/vmfs/volumes/c97af7e9-686a74ad/Auto-esx8.0-rhell9.3-efi-with-empty-cdrom/Auto-esx8.0-rhell9.3-efi-with-empty-cdrom-155bb14b.vswp"
+uuid.location = "56 4d 4b 9e d2 17 63 9b-98 0e 92 5d 77 2a a3 83"
+scsi0:0.redo = ""
+vmci0.id = "171426626"
+cleanShutdown = "FALSE"
diff --git a/tests/vmx2xmldata/esx-in-the-wild-12.xml 
b/tests/vmx2xmldata/esx-in-the-wild-12.xml
new file mode 100644
index 00..42184501d0
--- /dev/null
+++ b/tests/vmx2xmldata/esx-in-the-wild-12.xml
@@ -0,0 +1,39 @@
+
+  Auto-esx8.0-rhell9.3-efi-with-empty-cdrom
+  4220fca7-11dd-d67e-19cc-fcad0a37c342
+  2097152
+  2097152
+  1
+  
+1000
+  
+  
+hvm
+  
+  
+  destroy
+  restart
+  destroy
+  
+
+  
+  
+  
+
+
+  
+  
+  
+
+
+
+
+  
+  
+  
+
+
+  
+
+  
+
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index a43cab3108..785eee6d30 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -262,6 +262,7 @@ mymain(void)
 DO_TEST("esx-in-the-wild-9");
 DO_TEST("esx-in-the-wild-10");
 DO_TEST("esx-in-the-wild-11");
+DO_TEST("esx-in-the-wild-12");
 
 DO_TEST("gsx-in-the-wild-1");
 DO_TEST("gsx-in-the-wi

[PATCH 3/4] vmx: Separate disk target name generation into a function

2023-12-15 Thread Michal Privoznik
Signed-off-by: Michal Privoznik 
---
 src/vmx/vmx.c | 175 +++---
 1 file changed, 110 insertions(+), 65 deletions(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index af1c1640ae..399f03b419 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2136,6 +2136,113 @@ virVMXParseSATAController(virConf *conf, int 
controller, bool *present)
 }
 
 
+static int
+virXMXGenerateDiskTarget(virDomainDiskDef *def,
+ virDomainDef *vmdef,
+ int controllerOrBus,
+ int unit)
+{
+const char *prefix = NULL;
+unsigned int idx = 0;
+
+switch (def->bus) {
+case VIR_DOMAIN_DISK_BUS_SCSI:
+if (controllerOrBus < 0 || controllerOrBus > 3) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SCSI controller index %1$d out of [0..3] range"),
+   controllerOrBus);
+return -1;
+}
+
+if (unit < 0 || unit > vmdef->scsiBusMaxUnit || unit == 7) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SCSI unit index %1$d out of [0..6,8..%2$u] 
range"),
+   unit, vmdef->scsiBusMaxUnit);
+return -1;
+}
+
+idx = controllerOrBus * 15 + (unit < 7 ? unit : unit - 1);
+prefix = "sd";
+break;
+
+case VIR_DOMAIN_DISK_BUS_SATA:
+if (controllerOrBus < 0 || controllerOrBus > 3) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SATA controller index %1$d out of [0..3] range"),
+   controllerOrBus);
+return -1;
+}
+
+if (unit < 0 || unit >= 30) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("SATA unit index %1$d out of [0..29] range"),
+   unit);
+return -1;
+}
+
+idx = controllerOrBus * 30 + unit;
+prefix = "sd";
+break;
+
+case VIR_DOMAIN_DISK_BUS_IDE:
+if (controllerOrBus < 0 || controllerOrBus > 1) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("IDE bus index %1$d out of [0..1] range"),
+   controllerOrBus);
+return -1;
+}
+
+if (unit < 0 || unit > 1) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("IDE unit index %1$d out of [0..1] range"), unit);
+return -1;
+}
+idx = controllerOrBus * 2 + unit;
+prefix = "hd";
+break;
+
+case VIR_DOMAIN_DISK_BUS_FDC:
+if (controllerOrBus != 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("FDC controller index %1$d out of [0] range"),
+   controllerOrBus);
+return -1;
+}
+
+if (unit < 0 || unit > 1) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("FDC unit index %1$d out of [0..1] range"),
+   unit);
+return -1;
+}
+
+idx = unit;
+prefix = "fd";
+break;
+
+case VIR_DOMAIN_DISK_BUS_VIRTIO:
+case VIR_DOMAIN_DISK_BUS_XEN:
+case VIR_DOMAIN_DISK_BUS_USB:
+case VIR_DOMAIN_DISK_BUS_UML:
+case VIR_DOMAIN_DISK_BUS_SD:
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("Unsupported bus type '%1$s' for device type '%2$s'"),
+   virDomainDiskBusTypeToString(def->bus),
+   virDomainDiskDeviceTypeToString(def->device));
+return -1;
+break;
+
+case VIR_DOMAIN_DISK_BUS_NONE:
+case VIR_DOMAIN_DISK_BUS_LAST:
+virReportEnumRangeError(virDomainDiskBus, def->bus);
+return -1;
+break;
+}
+
+def->dst = virIndexToDiskName(idx, prefix);
+return 0;
+}
+
 
 static int
 virVMXParseDisk(virVMXContext *ctx, virDomainXMLOption *xmlopt, virConf *conf,
@@ -2208,60 +2315,11 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOption 
*xmlopt, virConf *conf,
 if (device == VIR_DOMAIN_DISK_DEVICE_DISK ||
 device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
 if (busType == VIR_DOMAIN_DISK_BUS_SCSI) {
-if (controllerOrBus < 0 || controllerOrBus > 3) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("SCSI controller index %1$d out of [0..3] 
range"),
-   controllerOrBus);
-goto cleanup;
-}
-
-if (unit < 0 || unit > vmdef->scsiBusMaxUnit || unit == 7) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("SCSI unit index %1$d out of [0..6,8..%2$u] 
range"),
-   unit, vmdef->scsiBusMaxUnit);
-goto cleanup;
-}
-
 prefix = g_strdup_printf("scsi%d:%d", controllerOrBus, unit);
-
-   

[PATCH 1/4] vmx: Accept empty fileName for cdrom-image

2023-12-15 Thread Michal Privoznik
Turns out, there are two ways to specify an empty CD-ROM drive in
a .vmx file:

  1) .fileName = "emptyBackingString"
  2) .fileName = ""

While we do parse 1) successfully, the code does not accept 2)
and an error is reported. Modify the code to treat both cases the
same.

Resolves: https://issues.redhat.com/browse/RHEL-19380
Signed-off-by: Michal Privoznik 
---
 src/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 26b89776e1..af1c1640ae 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2483,7 +2483,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOption 
*xmlopt, virConf *conf,
  */
 goto ignore;
 }
-} else if (fileName && STREQ(fileName, "emptyBackingString")) {
+} else if (fileName && (STREQ(fileName, "") ||
+STREQ(fileName, "emptyBackingString"))) {
 if (deviceType && STRCASENEQ(deviceType, "cdrom-image")) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%1$s' to be 
'cdrom-image' but found '%2$s'"),
-- 
2.41.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 0/4] vmx: A couple of disk related fixes

2023-12-15 Thread Michal Privoznik
The first patch fixes an issue.
The last one - I am not sure if it's not going to break something and
thus it's optional.

Michal Prívozník (4):
  vmx: Accept empty fileName for cdrom-image
  vmx2xmltest: Add another test case
  vmx: Separate disk target name generation into a function
  vmx: Ensure unique disk targets when parsing

 src/vmx/vmx.c| 199 +++
 tests/vmx2xmldata/esx-in-the-wild-12.vmx |  86 ++
 tests/vmx2xmldata/esx-in-the-wild-12.xml |  39 +
 tests/vmx2xmldata/esx-in-the-wild-8.xml  |   4 +-
 tests/vmx2xmltest.c  |   1 +
 5 files changed, 261 insertions(+), 68 deletions(-)
 create mode 100644 tests/vmx2xmldata/esx-in-the-wild-12.vmx
 create mode 100644 tests/vmx2xmldata/esx-in-the-wild-12.xml

-- 
2.41.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Efim Shevrin
Hello,

here are call traces with two threads generated by python script
// ==
[root@dandreev-vz-6-0-0-243-master libvirt]# gdb -p 288985
(gdb) t a a bt

Thread 2 (Thread 0x7f2112862640 (LWP 288986) "python3"):
#0  0x7f2121d4296f in poll () at /lib64/libc.so.6
#1  0x7f211444650c in g_main_context_iterate.constprop () at 
/lib64/libglib-2.0.so.0
#2  0x7f21143f1483 in g_main_loop_run () at /lib64/libglib-2.0.so.0
#3  0x7f211406800b in virNetClientIOEventLoop () at /lib64/libvirt.so.0
#4  0x7f2114068a0a in virNetClientIO () at /lib64/libvirt.so.0
#5  0x7f21140692c1 in virNetClientSendInternal () at /lib64/libvirt.so.0
#6  0x7f211406936d in virNetClientSendWithReply () at /lib64/libvirt.so.0
#7  0x7f2114061a1d in virNetClientProgramCall () at /lib64/libvirt.so.0
#8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
#9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
#10 0x7f21140d8435 in remoteDomainCreate () at /lib64/libvirt.so.0
#11 0x7f21141dd60c in virDomainCreate () at /lib64/libvirt.so.0
#12 0x7f21145c8114 in libvirt_virDomainCreate () at 
/usr/lib64/python3.9/site-packages/libvirtmod.cpython-39-x86_64-linux-gnu.so
#13 0x7f21221268a8 in cfunction_call () at /lib64/libpython3.9.so.1.0
#14 0x7f2122118814 in _PyObject_MakeTpCall () at /lib64/libpython3.9.so.1.0
#15 0x7f212211566e in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#16 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#17 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#18 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#19 0x7f21221103e8 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#20 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#21 0x7f21221133d2 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#22 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#23 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#24 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#25 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#26 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#27 0x7f2122125382 in method_vectorcall () at /lib64/libpython3.9.so.1.0
#28 0x7f21221d8c4a in t_bootstrap () at /lib64/libpython3.9.so.1.0
#29 0x7f21221d8bf8 in pythread_wrapper () at /lib64/libpython3.9.so.1.0
#30 0x7f2121c9f802 in start_thread () at /lib64/libc.so.6
#31 0x7f2121c3f450 in clone3 () at /lib64/libc.so.6

Thread 1 (Thread 0x7f21223cf740 (LWP 288985) "python3"):
#0  0x7f2121c9c39a in __futex_abstimed_wait_common () at /lib64/libc.so.6
#1  0x7f2121c9eba0 in pthread_cond_wait@@GLIBC_2.3.2 () at /lib64/libc.so.6
#2  0x7f2113f4982a in virCondWait () at /lib64/libvirt.so.0
#3  0x7f2113f1fee3 in virObjectWait () at /lib64/libvirt.so.0
#4  0x7f211406882a in virNetClientIO () at /lib64/libvirt.so.0
#5  0x7f21140692c1 in virNetClientSendInternal () at /lib64/libvirt.so.0
#6  0x7f211406936d in virNetClientSendWithReply () at /lib64/libvirt.so.0
#7  0x7f2114061a1d in virNetClientProgramCall () at /lib64/libvirt.so.0
#8  0x7f21140f79ac in callFull () at /lib64/libvirt.so.0
#9  0x7f21140f7a2f in call () at /lib64/libvirt.so.0
#10 0x7f21140f24eb in remoteNodeDeviceNumOfCaps () at /lib64/libvirt.so.0
#11 0x7f2114207a00 in virNodeDeviceNumOfCaps () at /lib64/libvirt.so.0
#12 0x7f21145d8edf in libvirt_virNodeDeviceListCaps.lto_priv.0 () at 
/usr/lib64/python3.9/site-packages/libvirtmod.cpython-39-x86_64-linux-gnu.so
#13 0x7f21221268a8 in cfunction_call () at /lib64/libpython3.9.so.1.0
#14 0x7f2122118814 in _PyObject_MakeTpCall () at /lib64/libpython3.9.so.1.0
#15 0x7f212211566e in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#16 0x7f212211d013 in function_code_fastcall () at 
/lib64/libpython3.9.so.1.0
#17 0x7f2122110650 in _PyEval_EvalFrameDefault () at 
/lib64/libpython3.9.so.1.0
#18 0x7f212210f06d in _PyEval_EvalCode () at /lib64/libpython3.9.so.1.0
#19 0x7f212218c495 in _PyEval_EvalCodeWithName () at 
/lib64/libpython3.9.so.1.0
--Type  for more, q to quit, c to continue without paging--
#20 0x7f212218c42d in PyEval_EvalCodeEx () at /lib64/libpython3.9.so.1.0
#21 0x7f212218c3df in PyEval_EvalCode () at /lib64/libpython3.9.so.1.0
#22 0x7f21221b7524 in run_eval_code_obj () at /lib64/libpython3.9.so.1.0
#23 0x7f21221b5da6 in run_mod () at /lib64/libpython3.9.so.1.0
#24 0x7f212208f0cb in pyrun_file.cold () at /lib64/libpython3.9.so.1.0
#25 0x7f21221bb253 in PyRun_SimpleFileExFlags () at 
/lib64/libpython3.9.so.1.0
#26 0x7f21221b7ee8 in Py_RunMain () at /lib64/libpython3.9.so.1.0
#27 0x7f212217f02d in Py_BytesMain () at /lib64/libp

[PATCH 18/19] qemuxml2argvtest: Add test cases covered only by qemuxml2xmltest - part 2

2023-12-15 Thread Peter Krempa
Add the rest of test cases which were tested only by qemuxml2xmltest.

All test cases added here have a '
---
 .../net-bandwidth.x86_64-latest.args  | 47 ++
 tests/qemuxml2argvdata/net-bandwidth.xml  |  2 +-
 .../net-bandwidth2.x86_64-latest.args | 44 +
 tests/qemuxml2argvdata/net-bandwidth2.xml |  2 +-
 .../net-coalesce.x86_64-latest.args   | 48 +++
 tests/qemuxml2argvdata/net-coalesce.xml   |  6 +--
 .../net-isolated-port.x86_64-latest.args  | 43 +
 tests/qemuxml2argvdata/net-isolated-port.xml  |  2 +-
 .../net-mtu.x86_64-latest.args| 46 ++
 tests/qemuxml2argvdata/net-mtu.xml|  4 +-
 .../net-openvswitch.x86_64-latest.args| 38 +++
 tests/qemuxml2argvdata/net-openvswitch.xml|  2 +-
 ...irtio-network-portgroup.x86_64-latest.args | 42 
 .../net-virtio-network-portgroup.xml  |  6 +--
 ...-virtio-teaming-network.x86_64-latest.args | 39 +++
 .../net-virtio-teaming-network.xml|  4 +-
 .../tap-vhost-incorrect.x86_64-latest.args| 40 
 .../qemuxml2argvdata/tap-vhost-incorrect.xml  |  4 +-
 .../tap-vhost.x86_64-latest.args  | 44 +
 tests/qemuxml2argvdata/tap-vhost.xml  |  2 +-
 tests/qemuxml2argvtest.c  | 10 
 .../net-bandwidth.x86_64-latest.xml   |  2 +-
 .../net-bandwidth2.x86_64-latest.xml  |  2 +-
 .../net-coalesce.x86_64-latest.xml|  6 +--
 .../net-isolated-port.x86_64-latest.xml   |  2 +-
 .../net-openvswitch.x86_64-latest.xml |  2 +-
 ...virtio-network-portgroup.x86_64-latest.xml |  6 +--
 ...t-virtio-teaming-network.x86_64-latest.xml |  4 +-
 .../tap-vhost-incorrect.x86_64-latest.xml |  4 +-
 .../tap-vhost.x86_64-latest.xml   |  2 +-
 30 files changed, 473 insertions(+), 32 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/net-bandwidth.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-bandwidth2.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-coalesce.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-isolated-port.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-mtu.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-openvswitch.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/net-virtio-network-portgroup.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/net-virtio-teaming-network.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/tap-vhost-incorrect.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/tap-vhost.x86_64-latest.args

diff --git a/tests/qemuxml2argvdata/net-bandwidth.x86_64-latest.args 
b/tests/qemuxml2argvdata/net-bandwidth.x86_64-latest.args
new file mode 100644
index 00..5dc47d316f
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-bandwidth.x86_64-latest.args
@@ -0,0 +1,47 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-f14-60 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-f14-60/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-f14-60/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-f14-60/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=f14-60,debug-threads=on \
+-S \
+-object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-f14-60/master-key.aes"}'
 \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=on \
+-accel kvm \
+-cpu qemu64 \
+-m size=1048576k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}' \
+-overcommit mem-lock=off \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid 38644c45-5227-a936-3b38-bc4f72c355bb \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot menu=on,strict=on \
+-device 
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-device 
'{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.0","addr":"0x6"}'
 \
+-blockdev 
'{"driver":"file","filename":"/var/lib/libvirt/images/f14-6.img","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"node-name":"libvirt-2-format","read-only":false,"driver":"qcow2","file":"libvirt-2-storage"}'
 \
+-device 
'{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"libvirt-2-format","id":"virtio-disk0","bootindex":2}'
 \
+-blockdev 
'{"driver":"file","filename":"/home/zippy/tmp/Fedora-14-x86_64-Live-KDE.iso","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"node-name":"libvirt-1-format","read-only":true,"driver":"raw","file":"libvirt-1-storage"}'
 \
+-device 
'{"driver":"ide-cd","bus":"ide.1","unit":0,"drive":"libvirt-1-format","id":"

[PATCH 19/19] qemuxml2argvtest: Add checker that all input files are used

2023-12-15 Thread Peter Krempa
To prevent regressions when refactoring tests and accidentally forgotten
input files make sure that qemuxml2argvtest is invoked for all input
files in tests/qemuxml2argvdata

Signed-off-by: Peter Krempa 
---
 tests/qemustatusxml2xmltest.c |  2 +-
 tests/qemuxml2argvtest.c  | 63 ++-
 tests/testutils.c | 14 
 tests/testutils.h |  2 ++
 tests/testutilsqemu.h |  1 +
 5 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c
index 4796b62853..f60378c691 100644
--- a/tests/qemustatusxml2xmltest.c
+++ b/tests/qemustatusxml2xmltest.c
@@ -73,7 +73,7 @@ mymain(void)
 {
 int ret = 0;
 g_autoptr(virConnect) conn = NULL;
-struct testQemuConf testConf = { NULL, NULL, NULL, NULL };
+struct testQemuConf testConf = { NULL, NULL, NULL, NULL, NULL };

 if (qemuTestDriverInit(&driver) < 0)
 return EXIT_FAILURE;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 48ee433495..0ae6700d95 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -621,6 +621,9 @@ testCompareXMLToArgv(const void *data)
 virArch arch = VIR_ARCH_NONE;
 g_autoptr(virIdentity) sysident = virIdentityGetSystem();

+/* mark test case as used */
+ignore_value(g_hash_table_remove(info->conf->existingTestCases, 
info->infile));
+
 if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
 goto cleanup;

@@ -809,22 +812,76 @@ testInfoSetPaths(struct testQemuInfo *info,
   abs_srcdir, info->name, suffix ? suffix 
: "");
 }

+
+static int
+testConfXMLCheck(GHashTable *existingTestCases)
+{
+g_autofree virHashKeyValuePair *items = virHashGetItems(existingTestCases, 
NULL, true);
+size_t i;
+int ret = 0;
+
+for (i = 0; items[i].key; i++) {
+if (ret == 0)
+fprintf(stderr, "\n");
+
+fprintf(stderr, "unused input file: %s\n", (const char *) 
items[i].key);
+ret = -1;
+}
+
+return ret;
+}
+
+
+static int
+testConfXMLEnumerate(GHashTable *existingTestCases)
+{
+struct dirent *ent;
+g_autoptr(DIR) dir = NULL;
+int rc;
+
+/* If VIR_TEST_RANGE is in use don't bother filling in the data, which
+ * also makes testConfXMLCheck succeed. */
+if (virTestHasRangeBitmap())
+return 0;
+
+if (virDirOpen(&dir, abs_srcdir "/qemuxml2argvdata") < 0)
+return -1;
+
+while ((rc = virDirRead(dir, &ent, abs_srcdir "/qemuxml2argvdata")) > 0) {
+if (virStringHasSuffix(ent->d_name, ".xml")) {
+g_hash_table_insert(existingTestCases,
+g_strdup_printf(abs_srcdir 
"/qemuxml2argvdata/%s", ent->d_name),
+NULL);
+}
+}
+
+return rc;
+}
+
+
 static int
 mymain(void)
 {
 int ret = 0;
 g_autoptr(GHashTable) duplicateTests = virHashNew(NULL);
+g_autoptr(GHashTable) existingTestCases = virHashNew(NULL);
 g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps();
 g_autoptr(GHashTable) qapiSchemaCache = virHashNew((GDestroyNotify) 
g_hash_table_unref);
 g_autoptr(GHashTable) capscache = virHashNew(virObjectUnref);
 struct testQemuConf testConf = { .capslatest = capslatest,
  .capscache = capscache,
  .qapiSchemaCache = qapiSchemaCache,
- .duplicateTests = duplicateTests };
+ .duplicateTests = duplicateTests,
+ .existingTestCases = existingTestCases };

 if (!capslatest)
 return EXIT_FAILURE;

+/* enumerate and store all available test cases to verify at the end that
+ * all of them were invoked */
+if (testConfXMLEnumerate(existingTestCases) < 0)
+return EXIT_FAILURE;
+
 /* Set the timezone because we are mocking the time() function.
  * If we don't do that, then localtime() may return unpredictable
  * results. In order to detect things that just work by a blind
@@ -2592,6 +2649,10 @@ mymain(void)
 DO_TEST_CAPS_LATEST("tap-vhost-incorrect");
 DO_TEST_CAPS_LATEST("tap-vhost");

+/* check that all input files were actually used here */
+if (testConfXMLCheck(existingTestCases) < 0)
+ret = -1;
+
 qemuTestDriverFree(&driver);
 virFileWrapperClearPrefixes();

diff --git a/tests/testutils.c b/tests/testutils.c
index e546422941..b20e447b99 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -746,6 +746,20 @@ virTestGetRegenerate(void)
 return testRegenerate;
 }

+
+/**
+ * virTestHasRangeBitmap:
+ *
+ * Returns whether the test was invoked with VIR_TEST_RANGE declared thus
+ * limiting the run only on specific test cases.
+ */
+bool
+virTestHasRangeBitmap(void)
+{
+return !!testBitmap;
+}
+
+
 static int
 virTestSetEnvPath(void)
 {
diff --git a/tests

[PATCH 16/19] qemuxml2argvtest: Enable 'graphics-listen-network' case

2023-12-15 Thread Peter Krempa
Use the data from 'nat-network' network definition to enable the test
case also for xml2argvtest.

Since the network listen bit doesn't need any plug definition just use
an empty string.

Signed-off-by: Peter Krempa 
---
 ...graphics-listen-network.x86_64-latest.args | 37 +++
 .../graphics-listen-network.xml   |  2 +-
 tests/qemuxml2argvtest.c  |  2 +
 .../graphics-listen-network.x86_64-latest.xml |  2 +-
 4 files changed, 41 insertions(+), 2 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/graphics-listen-network.x86_64-latest.args

diff --git a/tests/qemuxml2argvdata/graphics-listen-network.x86_64-latest.args 
b/tests/qemuxml2argvdata/graphics-listen-network.x86_64-latest.args
new file mode 100644
index 00..c49abca749
--- /dev/null
+++ b/tests/qemuxml2argvdata/graphics-listen-network.x86_64-latest.args
@@ -0,0 +1,37 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}'
 \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device 
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-blockdev 
'{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}'
 \
+-device 
'{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-format","id":"ide0-0-0","bootindex":1}'
 \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-vnc 192.168.122.1:3,audiodev=audio1 \
+-device '{"driver":"cirrus-vga","id":"video0","bus":"pci.0","addr":"0x2"}' \
+-device 
'{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x3"}' \
+-sandbox 
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/graphics-listen-network.xml 
b/tests/qemuxml2argvdata/graphics-listen-network.xml
index f1ab81ca0b..cc7301149f 100644
--- a/tests/qemuxml2argvdata/graphics-listen-network.xml
+++ b/tests/qemuxml2argvdata/graphics-listen-network.xml
@@ -25,7 +25,7 @@
 
 
 
-  
+  
 
 
   
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7197fd35db..cb2d2b25e3 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2580,6 +2580,8 @@ mymain(void)
 DO_TEST_CAPS_LATEST("vhost-user-fs-sock");
 DO_TEST_CAPS_ARCH_LATEST("video-virtio-gpu-ccw-auto", "s390x");

+DO_TEST_CAPS_LATEST("graphics-listen-network");
+
 qemuTestDriverFree(&driver);
 virFileWrapperClearPrefixes();

diff --git a/tests/qemuxml2xmloutdata/graphics-listen-network.x86_64-latest.xml 
b/tests/qemuxml2xmloutdata/graphics-listen-network.x86_64-latest.xml
index ab4aa8cafa..af89470138 100644
--- a/tests/qemuxml2xmloutdata/graphics-listen-network.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/graphics-listen-network.x86_64-latest.xml
@@ -33,7 +33,7 @@
 
 
 
-  
+  
 
 
 
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 17/19] virnetworkportxml2xmltest: Add simple versions of bridge/network tests

2023-12-15 Thread Peter Krempa
Add versions stripping vlans and bandwidth setup so that they can be
used in qemuxml2argvtest for interfaces which don't support the above.

Signed-off-by: Peter Krempa 
---
 tests/virnetworkportxml2xmldata/plug-bridge-basic.xml | 11 +++
 .../virnetworkportxml2xmldata/plug-network-basic.xml  | 10 ++
 tests/virnetworkportxml2xmltest.c |  2 ++
 3 files changed, 23 insertions(+)
 create mode 100644 tests/virnetworkportxml2xmldata/plug-bridge-basic.xml
 create mode 100644 tests/virnetworkportxml2xmldata/plug-network-basic.xml

diff --git a/tests/virnetworkportxml2xmldata/plug-bridge-basic.xml 
b/tests/virnetworkportxml2xmldata/plug-bridge-basic.xml
new file mode 100644
index 00..5569297b79
--- /dev/null
+++ b/tests/virnetworkportxml2xmldata/plug-bridge-basic.xml
@@ -0,0 +1,11 @@
+
+  5d744f21-ba4a-4d6e-bdb2-30a35ff3207d
+  
+memtest
+d54df46f-1ab5-4a22-8618-4560ef5fac2c
+  
+  web1
+  
+  
+  
+
diff --git a/tests/virnetworkportxml2xmldata/plug-network-basic.xml 
b/tests/virnetworkportxml2xmldata/plug-network-basic.xml
new file mode 100644
index 00..549b65a0d1
--- /dev/null
+++ b/tests/virnetworkportxml2xmldata/plug-network-basic.xml
@@ -0,0 +1,10 @@
+
+  5d744f21-ba4a-4d6e-bdb2-30a35ff3207d
+  
+memtest
+d54df46f-1ab5-4a22-8618-4560ef5fac2c
+  
+  web1
+  
+  
+
diff --git a/tests/virnetworkportxml2xmltest.c 
b/tests/virnetworkportxml2xmltest.c
index 21e3c6f697..2949fa9638 100644
--- a/tests/virnetworkportxml2xmltest.c
+++ b/tests/virnetworkportxml2xmltest.c
@@ -81,11 +81,13 @@ mymain(void)

 DO_TEST("plug-none");
 DO_TEST("plug-bridge");
+DO_TEST("plug-bridge-basic");
 DO_TEST("plug-bridge-mactbl");
 DO_TEST("plug-direct");
 DO_TEST("plug-hostdev-pci");
 DO_TEST("plug-hostdev-pci-unmanaged");
 DO_TEST("plug-network");
+DO_TEST("plug-network-basic");

 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 15/19] qemuxml2xmltest: Introduce fake network driver

2023-12-15 Thread Peter Krempa
In order to be able to use '
---
 tests/qemuxml2argvtest.c | 98 
 1 file changed, 98 insertions(+)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 13d279b301..7197fd35db 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -257,6 +257,103 @@ static virNWFilterDriver fakeNWFilterDriver = {
 };


+/* name of the fake network shall be constructed as:
+ *  NETWORKXMLNAME;NETWORKPORTXMLNAME
+ *  where:
+ *  NETWORKXMLNAME resolves to abs_srcdir/networkxml2xmlin/NETWORKXMLNAME.xml
+ *  NETWORKPORTXMLNAME resolves to 
abs_srcdir/virnetworkportxml2xmldata/NETWORKPORTXMLNAME.xml
+ */
+static virNetworkPtr
+fakeNetworkLookupByName(virConnectPtr conn,
+const char *name)
+{
+unsigned char uuid[VIR_UUID_BUFLEN];
+g_autofree char *netname = g_strdup(name);
+g_autofree char *path = NULL;
+char *tmp;
+
+memset(uuid, 0, VIR_UUID_BUFLEN);
+
+if ((tmp = strchr(netname, ';'))) {
+*tmp = '\0';
+} else {
+virReportError(VIR_ERR_NO_NETWORK, "Malformed fake network name '%s'. 
See fakeNetworkLookupByName.", name);
+return NULL;
+}
+
+path = g_strdup_printf(abs_srcdir "/networkxml2xmlin/%s.xml", netname);
+
+if (!virFileExists(path)) {
+virReportError(VIR_ERR_NO_NETWORK, "fake network '%s' not found", 
path);
+return NULL;
+}
+
+return virGetNetwork(conn, name, uuid);
+}
+
+
+static char *
+fakeNetworkGetXMLDesc(virNetworkPtr network,
+  unsigned int noflags G_GNUC_UNUSED)
+{
+g_autofree char *netname = g_strdup(network->name);
+g_autofree char *path = NULL;
+char *xml = NULL;
+
+*(strchr(netname, ';')) = '\0';
+
+path = g_strdup_printf(abs_srcdir "/networkxml2xmlin/%s.xml", netname);
+
+if (virFileReadAll(path, 4 * 1024, &xml) < 0)
+return NULL;
+
+return xml;
+}
+
+
+static virNetworkPortPtr
+fakeNetworkPortCreateXML(virNetworkPtr net,
+ const char *xmldesc G_GNUC_UNUSED,
+ unsigned int noflags G_GNUC_UNUSED)
+{
+unsigned char uuid[VIR_UUID_BUFLEN];
+g_autofree char *portname = g_strdup(strchr(net->name, ';') + 1);
+g_autofree char *path = g_strdup_printf(abs_srcdir 
"/virnetworkportxml2xmldata/%s.xml", portname);
+
+memset(uuid, 0, VIR_UUID_BUFLEN);
+
+if (!virFileExists(path)) {
+virReportError(VIR_ERR_NO_NETWORK_PORT, "fake network port '%s' not 
found", path);
+return NULL;
+}
+
+return virGetNetworkPort(net, uuid);
+}
+
+
+static char *
+fakeNetworkPortGetXMLDesc(virNetworkPortPtr port,
+  unsigned int noflags G_GNUC_UNUSED)
+{
+g_autofree char *portname = g_strdup(strchr(port->net->name, ';') + 1);
+g_autofree char *path = g_strdup_printf(abs_srcdir 
"/virnetworkportxml2xmldata/%s.xml", portname);
+char *xml = NULL;
+
+if (virFileReadAll(path, 4 * 1024, &xml) < 0)
+return NULL;
+
+return xml;
+}
+
+
+static virNetworkDriver fakeNetworkDriver = {
+.networkLookupByName = fakeNetworkLookupByName,
+.networkGetXMLDesc = fakeNetworkGetXMLDesc,
+.networkPortCreateXML = fakeNetworkPortCreateXML,
+.networkPortGetXMLDesc = fakeNetworkPortGetXMLDesc,
+};
+
+
 static void
 testUpdateQEMUCapsHostCPUModel(virQEMUCaps *qemuCaps, virArch hostArch)
 {
@@ -546,6 +643,7 @@ testCompareXMLToArgv(const void *data)
 conn->secretDriver = &fakeSecretDriver;
 conn->storageDriver = &fakeStorageDriver;
 conn->nwfilterDriver = &fakeNWFilterDriver;
+conn->networkDriver = &fakeNetworkDriver;

 virSetConnectInterface(conn);
 virSetConnectNetwork(conn);
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 14/19] qemuxml2argvmock: Mock virNetDevSetMTU

2023-12-15 Thread Peter Krempa
Unfortunately the network backend commandline formatter attempts to also
setup the backend itself, which it really should not.

For now make sure qemuxml2argvtest can call virNetDevSetMTU.

Signed-off-by: Peter Krempa 
---
 src/util/virnetdev.h | 2 +-
 tests/qemuxml2argvmock.c | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 05daed09e9..c287a7b272 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -202,7 +202,7 @@ int virNetDevSetCoalesce(const char *ifname,

 int virNetDevSetMTU(const char *ifname,
 int mtu)
-ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
+ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE;
 int virNetDevSetMTUFromDevice(const char *ifname,
   const char *otherifname)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index f2696bd4c3..9cc97199c4 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -284,3 +284,11 @@ virIdentityEnsureSystemToken(void)
 {
 return g_strdup("3de80bcbf22d4833897f1638e01be9b2");
 }
+
+
+int
+virNetDevSetMTU(const char *ifname G_GNUC_UNUSED,
+int mtu G_GNUC_UNUSED)
+{
+return 0;
+}
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 13/19] qemu: process: Separate setup of network device objects

2023-12-15 Thread Peter Krempa
Separate the SLIRP bits from 'qemuProcessNetworkPrepareDevices' and do
the setup of the internal data when setting up domain data.

This will allow tests to use the same code path to lookup data for a
network.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_process.c | 45 ++---
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fc05b4b24f..b1a225f5e5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5705,12 +5705,8 @@ qemuProcessInit(virQEMUDriver *driver,
 }


-/**
- * qemuProcessNetworkPrepareDevices
- */
 static int
-qemuProcessNetworkPrepareDevices(virQEMUDriver *driver,
- virDomainObj *vm)
+qemuProcessPrepareDomainNetwork(virDomainObj *vm)
 {
 virDomainDef *def = vm->def;
 qemuDomainObjPrivate *priv = vm->privateData;
@@ -5762,15 +5758,32 @@ qemuProcessNetworkPrepareDevices(virQEMUDriver *driver,

 if (virDomainHostdevInsert(def, hostdev) < 0)
 return -1;
-} else if (actualType == VIR_DOMAIN_NET_TYPE_USER &&
-   net->backend.type == VIR_DOMAIN_NET_BACKEND_DEFAULT &&
-   !priv->disableSlirp &&
-   virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
-if (qemuInterfacePrepareSlirp(driver, net) < 0)
+}
+}
+return 0;
+}
+
+
+static int
+qemuProcessPrepareHostNetwork(virDomainObj *vm)
+{
+qemuDomainObjPrivate *priv = vm->privateData;
+size_t i;
+
+for (i = 0; i < vm->def->nnets; i++) {
+virDomainNetDef *net = vm->def->nets[i];
+virDomainNetType actualType = virDomainNetGetActualType(net);
+
+if (actualType == VIR_DOMAIN_NET_TYPE_USER &&
+net->backend.type == VIR_DOMAIN_NET_BACKEND_DEFAULT &&
+!priv->disableSlirp &&
+virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
+if (qemuInterfacePrepareSlirp(priv->driver, net) < 0)
 return -1;
- }
+}

 }
+
 return 0;
 }

@@ -6627,6 +6640,10 @@ qemuProcessPrepareDomain(virQEMUDriver *driver,
 if (qemuProcessPrepareDomainHostdevs(vm, priv) < 0)
 return -1;

+VIR_DEBUG("Setting up network devices");
+if (qemuProcessPrepareDomainNetwork(vm) < 0)
+return -1;
+
 VIR_DEBUG("Prepare chardev source backends");
 if (qemuProcessPrepareChardevSource(vm->def, cfg) < 0)
 return -1;
@@ -7192,12 +7209,8 @@ qemuProcessPrepareHost(virQEMUDriver *driver,
 if (qemuProcessOpenVhostVsock(vm->def->vsock) < 0)
 return -1;
 }
-/* network devices must be "prepared" before hostdevs, because
- * setting up a network device might create a new hostdev that
- * will need to be setup.
- */
 VIR_DEBUG("Preparing network devices");
-if (qemuProcessNetworkPrepareDevices(driver, vm) < 0)
+if (qemuProcessPrepareHostNetwork(vm) < 0)
 return -1;

 /* Must be run before security labelling */
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 12/19] qemuxml2xmltest: Delete 'interface-driver' case

2023-12-15 Thread Peter Krempa
Everything this XML tests is already explicitly covered in other tests.

Signed-off-by: Peter Krempa 
---
 tests/qemuxml2argvdata/interface-driver.xml   | 54 ---
 .../interface-driver.x86_64-latest.xml| 67 ---
 tests/qemuxml2xmltest.c   |  1 -
 3 files changed, 122 deletions(-)
 delete mode 100644 tests/qemuxml2argvdata/interface-driver.xml
 delete mode 100644 tests/qemuxml2xmloutdata/interface-driver.x86_64-latest.xml

diff --git a/tests/qemuxml2argvdata/interface-driver.xml 
b/tests/qemuxml2argvdata/interface-driver.xml
deleted file mode 100644
index 8c8f043a93..00
--- a/tests/qemuxml2argvdata/interface-driver.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-
-  test
-  15d091de-0181-456b-9554-e4382dc1f1ab
-  1048576
-  1048576
-  1
-  
-hvm
-
-
-
-  
-  
-  destroy
-  restart
-  restart
-  
-/usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
-
-  
-  
-  
-  
-  
-
-
-
-  
-
-
-
-
-  
-  
-  
-  
-
-
-  
-
-
-  
-
-
-
-
-  
-
diff --git a/tests/qemuxml2xmloutdata/interface-driver.x86_64-latest.xml 
b/tests/qemuxml2xmloutdata/interface-driver.x86_64-latest.xml
deleted file mode 100644
index be40782604..00
--- a/tests/qemuxml2xmloutdata/interface-driver.x86_64-latest.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-  test
-  15d091de-0181-456b-9554-e4382dc1f1ab
-  1048576
-  1048576
-  1
-  
-hvm
-
-
-
-  
-  
-qemu64
-  
-  
-  destroy
-  restart
-  restart
-  
-/usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
-
-  
-  
-  
-  
-  
-
-
-  
-
-
-  
-
-
-  
-
-
-
-  
-  
-  
-  
-  
-
-
-  
-
-  
-
-
-  
-
-
-
-
-
-  
-
-  
-
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index df7c9da240..4e39763dc7 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -477,7 +477,6 @@ mymain(void)
 DO_TEST_CAPS_ARCH_LATEST("iothreads-virtio-scsi-ccw", "s390x");
 DO_TEST_CAPS_LATEST("lease");
 DO_TEST_CAPS_LATEST("event_idx");
-DO_TEST_CAPS_LATEST("interface-driver");
 DO_TEST_CAPS_LATEST("net-server");
 DO_TEST_CAPS_LATEST("virtio-lun");

-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 08/19] qemuxml2argvtest: Add test cases covered only by qemuxml2xmltest - part 1

2023-12-15 Thread Peter Krempa
There were plenty of test cases invoked only from qemuxml2xmltest but
not from qemuxml2argvtest, either by accident or it was deemed unneeded.

Bulk-add all test cases which fit the above description which don't
require faking the network driver. Use same invocation as present in
qemuxml2xmltest.

Arguably in certain cases we could move the test case to
genericxml2xmltest, but this covers the cases when that would not be
appropriate.

Tests requiring the network driver will be bulk-added when the fake
network driver will be implemented.

This patch also allows the use of FLAG_SKIP_CONFIG_ACTIVE in
qemuxml2argvtest although the flag will be dormant for now.

Signed-off-by: Peter Krempa 
---
 ...nu-disable-with-timeout.x86_64-latest.args | 36 +++
 ...hannel-unix-source-path.x86_64-latest.args | 45 ++
 .../chardev-label.x86_64-latest.args  | 41 +
 .../console-compat2.x86_64-latest.args| 40 +
 .../cpu-empty.x86_64-latest.args  | 33 ++
 ...cpu-host-model-features.x86_64-latest.args | 33 ++
 .../cpu-numa-disordered.x86_64-latest.args| 38 
 .../disk-active-commit.x86_64-latest.args | 38 
 .../disk-mirror-old.x86_64-latest.args| 45 ++
 .../disk-mirror.x86_64-latest.args| 48 +++
 .../disk-network-vxhs.x86_64-5.0.0.args   | 35 +++
 .../downscript.x86_64-latest.args | 43 +
 .../hostdev-mdev-display.x86_64-latest.args   | 34 +++
 ...ev-scsi-autogen-address.x86_64-latest.args | 60 +++
 ...hostdev-scsi-large-unit.x86_64-latest.args | 39 
 .../hostdev-scsi-shareable.x86_64-latest.args | 39 
 .../qemuxml2argvdata/lease.x86_64-latest.args | 39 
 .../memorybacking-set.x86_64-latest.args  | 33 ++
 .../memorybacking-unset.x86_64-latest.args| 33 ++
 .../metadata-duplicate.x86_64-latest.args | 36 +++
 .../metadata.x86_64-latest.args   | 36 +++
 .../net-midonet.x86_64-latest.args| 38 
 ...d-auto-vcpu-no-numatune.x86_64-latest.args | 36 +++
 ...static-vcpu-no-numatune.x86_64-latest.args | 36 +++
 ...vcpus-topology-mismatch.x86_64-latest.args | 34 +++
 .../panic-pseries.ppc64-latest.args   | 34 +++
 .../pcihole64-gib.x86_64-latest.args  | 34 +++
 .../s390-defaultconsole.s390x-latest.args | 33 ++
 .../s390-panic.s390x-latest.args  | 35 +++
 ...eclabel-device-multiple.x86_64-latest.args | 36 +++
 ...el-dynamic-none-relabel.x86_64-latest.args | 37 
 .../seclabel-dynamic-none.x86_64-latest.args  | 36 +++
 ...serial-target-port-auto.x86_64-latest.args | 42 +
 .../vhost-user-fs-sock.x86_64-latest.args | 34 +++
 ...ideo-virtio-gpu-ccw-auto.s390x-latest.args | 36 +++
 tests/qemuxml2argvtest.c  | 39 
 36 files changed, 1364 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/boot-menu-disable-with-timeout.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/channel-unix-source-path.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/chardev-label.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/console-compat2.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/cpu-empty.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/cpu-host-model-features.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/cpu-numa-disordered.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-active-commit.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-mirror-old.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-mirror.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-network-vxhs.x86_64-5.0.0.args
 create mode 100644 tests/qemuxml2argvdata/downscript.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/hostdev-mdev-display.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/hostdev-scsi-autogen-address.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/hostdev-scsi-large-unit.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/hostdev-scsi-shareable.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/lease.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/memorybacking-set.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/memorybacking-unset.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/metadata-duplicate.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/metadata.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-midonet.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/numad-auto-vcpu-no-numatune.x86_64-latest.args
 create mode 100644 
tests/qemuxml2argvdata/numad-static-vcpu-no-numa

[PATCH 11/19] qemuxml*test: Improve 'vhost_queues' test case

2023-12-15 Thread Peter Krempa
Modify the test case so that it can be used also for qemuxml2argvtest
by removing invalid configuration (interface type='user' + queues),
clean up unneeded disks and rename it accordingly. Also test the
ioeventfd.

Signed-off-by: Peter Krempa 
---
 .../net-virtio-vhost.x86_64-latest.args   | 42 +++
 ...{vhost_queues.xml => net-virtio-vhost.xml} | 25 +--
 tests/qemuxml2argvtest.c  |  1 +
 ...xml => net-virtio-vhost.x86_64-latest.xml} | 29 +++--
 tests/qemuxml2xmltest.c   |  2 +-
 5 files changed, 69 insertions(+), 30 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/net-virtio-vhost.x86_64-latest.args
 rename tests/qemuxml2argvdata/{vhost_queues.xml => net-virtio-vhost.xml} (67%)
 rename tests/qemuxml2xmloutdata/{vhost_queues.x86_64-latest.xml => 
net-virtio-vhost.x86_64-latest.xml} (78%)

diff --git a/tests/qemuxml2argvdata/net-virtio-vhost.x86_64-latest.args 
b/tests/qemuxml2argvdata/net-virtio-vhost.x86_64-latest.args
new file mode 100644
index 00..eabe768169
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-virtio-vhost.x86_64-latest.args
@@ -0,0 +1,42 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-test \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-test/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-test/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-test/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=test,debug-threads=on \
+-S \
+-object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-test/master-key.aes"}'
 \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=1048576k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid bba65c0e-c049-934f-b6aa-4e2c0582acdf \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot menu=on,strict=on \
+-device 
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-device 
'{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.0","addr":"0x6"}'
 \
+-netdev 
'{"type":"tap","fds":"3:4:5:6:7","vhost":true,"vhostfds":"44:45:46:47:48","id":"hostnet0"}'
 \
+-device 
'{"driver":"virtio-net-pci","mq":true,"vectors":12,"netdev":"hostnet0","id":"net0","mac":"52:54:00:e5:48:58","bus":"pci.0","addr":"0x2"}'
 \
+-netdev '{"type":"tap","fd":"3","vhost":true,"vhostfd":"44","id":"hostnet1"}' \
+-device 
'{"driver":"virtio-net-pci","ioeventfd":true,"netdev":"hostnet1","id":"net1","mac":"52:54:00:e5:48:59","bus":"pci.0","addr":"0x3"}'
 \
+-netdev 
'{"type":"tap","fds":"3:4:5:6:7","vhost":true,"vhostfds":"44:45:46:47:48","id":"hostnet2"}'
 \
+-device 
'{"driver":"virtio-net-pci","ioeventfd":true,"mq":true,"vectors":12,"netdev":"hostnet2","id":"net2","mac":"52:54:00:e5:48:5a","bus":"pci.0","addr":"0x4"}'
 \
+-chardev pty,id=charserial0 \
+-device 
'{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-device 
'{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x5"}' \
+-sandbox 
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/vhost_queues.xml 
b/tests/qemuxml2argvdata/net-virtio-vhost.xml
similarity index 67%
rename from tests/qemuxml2argvdata/vhost_queues.xml
rename to tests/qemuxml2argvdata/net-virtio-vhost.xml
index 2e38f2dad3..9d1feabe68 100644
--- a/tests/qemuxml2argvdata/vhost_queues.xml
+++ b/tests/qemuxml2argvdata/net-virtio-vhost.xml
@@ -16,30 +16,27 @@
   restart
   
 /usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
-
-  
-  
-  
-  
-  
-
 
 
   
 
 
 
-
+
   
   
   
 
+
+  
+  
+  
+
+
+  
+  
+  
+
 
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 22fd35809b..13d279b301 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1379,6 +1379,7 @@ mymain(void)
 DO_TEST_CAPS_LATEST("net-virtio-device");
 DO_TEST_CAPS_LATEST("net-virtio-disable-offloads");
 DO_TEST_CAPS_LATEST("net-virtio-netdev");
+DO_TEST_CAPS_LATEST("net-virtio-vhost");
 DO_TEST_CAPS_ARCH_LATEST("net-virtio-ccw", "s390x");
 DO_TEST_CAPS_LATEST("net-virtio-rxtxqueuesize");
 DO_TEST_CAPS_LATEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size");
diff --git a/tests/qemuxml2xmloutdata/vhost_queues.x86_64-latest.xml 
b/tests/qemuxml2xmloutdata/net-virtio-vhost.x86_64-latest.xml
similarity index 78%
rename from tests/qemuxml2xmloutdata/vhost_queues.x86_64-latest.xml
rename to 

[PATCH 10/19] qemuxml2*test: Add specific test case for interface link state

2023-12-15 Thread Peter Krempa
Test both linkstates in an explicit test case. Note that link state is
setup via monitor, thus not visible on the commandline.

Signed-off-by: Peter Krempa 
---
 .../net-linkstate.x86_64-latest.args  | 36 +++
 tests/qemuxml2argvdata/net-linkstate.xml  | 34 ++
 tests/qemuxml2argvtest.c  |  1 +
 .../net-linkstate.x86_64-latest.xml   | 44 +++
 tests/qemuxml2xmltest.c   |  1 +
 5 files changed, 116 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/net-linkstate.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/net-linkstate.xml
 create mode 100644 tests/qemuxml2xmloutdata/net-linkstate.x86_64-latest.xml

diff --git a/tests/qemuxml2argvdata/net-linkstate.x86_64-latest.args 
b/tests/qemuxml2argvdata/net-linkstate.x86_64-latest.args
new file mode 100644
index 00..ba1608bf2e
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-linkstate.x86_64-latest.args
@@ -0,0 +1,36 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}'
 \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device 
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-netdev '{"type":"user","id":"hostnet0"}' \
+-device 
'{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}'
 \
+-netdev '{"type":"user","id":"hostnet1"}' \
+-device 
'{"driver":"virtio-net-pci","netdev":"hostnet1","id":"net1","mac":"00:11:22:33:44:66","bus":"pci.0","addr":"0x3"}'
 \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-sandbox 
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/net-linkstate.xml 
b/tests/qemuxml2argvdata/net-linkstate.xml
new file mode 100644
index 00..41aaabe8ae
--- /dev/null
+++ b/tests/qemuxml2argvdata/net-linkstate.xml
@@ -0,0 +1,34 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-x86_64
+
+
+
+
+  
+  
+  
+
+
+  
+  
+  
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 06fdd02b76..22fd35809b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1384,6 +1384,7 @@ mymain(void)
 DO_TEST_CAPS_LATEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size");
 DO_TEST_CAPS_LATEST("net-virtio-teaming");
 DO_TEST_CAPS_LATEST("net-virtio-teaming-hostdev");
+DO_TEST_CAPS_LATEST("net-linkstate");
 DO_TEST_CAPS_LATEST("net-eth");
 DO_TEST_CAPS_LATEST("net-eth-ifname");
 DO_TEST_CAPS_LATEST("net-eth-names");
diff --git a/tests/qemuxml2xmloutdata/net-linkstate.x86_64-latest.xml 
b/tests/qemuxml2xmloutdata/net-linkstate.x86_64-latest.xml
new file mode 100644
index 00..6a50c13f6d
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/net-linkstate.x86_64-latest.xml
@@ -0,0 +1,44 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219136
+  219136
+  1
+  
+hvm
+
+  
+  
+qemu64
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-x86_64
+
+  
+
+
+  
+
+
+
+  
+  
+  
+  
+
+
+  
+  
+  
+  
+
+
+
+
+
+  
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index e04001156c..466620bd56 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -383,6 +383,7 @@ mymain(void)
 DO_TEST_CAPS_LATEST("net-virtio");
 DO_TEST_CAPS_LATEST("net-virtio-device");
 DO_TEST_CAPS_LATEST("net-virtio-disable-offloads");
+DO_TEST_CAPS_LATEST("net-linkstate");
 DO_TEST_CAPS_LATEST("net-eth");
 DO_TEST_CAPS_LATEST("net-eth-ifname");
 DO_TEST_CAPS_LATEST("net-eth-hostip");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.

[PATCH 09/19] qemuxml2xmltest: Move 'graphics-listen-network2' case go genericxml2xmltest

2023-12-15 Thread Peter Krempa
The tested configuration is not valid for a qemu VM. Move it to the
generic test.

Signed-off-by: Peter Krempa 
---
 .../graphics-listen-network2.xml  |  0
 .../graphics-listen-network2.xml} | 19 +++
 tests/genericxml2xmltest.c|  1 +
 tests/qemuxml2xmltest.c   |  1 -
 4 files changed, 4 insertions(+), 17 deletions(-)
 rename tests/{qemuxml2argvdata => 
genericxml2xmlindata}/graphics-listen-network2.xml (100%)
 rename tests/{qemuxml2xmloutdata/graphics-listen-network2.x86_64-latest.xml => 
genericxml2xmloutdata/graphics-listen-network2.xml} (59%)

diff --git a/tests/qemuxml2argvdata/graphics-listen-network2.xml 
b/tests/genericxml2xmlindata/graphics-listen-network2.xml
similarity index 100%
rename from tests/qemuxml2argvdata/graphics-listen-network2.xml
rename to tests/genericxml2xmlindata/graphics-listen-network2.xml
diff --git 
a/tests/qemuxml2xmloutdata/graphics-listen-network2.x86_64-latest.xml 
b/tests/genericxml2xmloutdata/graphics-listen-network2.xml
similarity index 59%
rename from tests/qemuxml2xmloutdata/graphics-listen-network2.x86_64-latest.xml
rename to tests/genericxml2xmloutdata/graphics-listen-network2.xml
index e13bd7fe74..e8befe696c 100644
--- a/tests/qemuxml2xmloutdata/graphics-listen-network2.x86_64-latest.xml
+++ b/tests/genericxml2xmloutdata/graphics-listen-network2.xml
@@ -8,9 +8,6 @@
 hvm
 
   
-  
-qemu64
-  
   
   destroy
   restart
@@ -18,31 +15,21 @@
   
 /usr/bin/qemu-system-x86_64
 
-  
   
   
   
 
-
-  
-
-
-  
-
-
+
+
 
 
 
   
   
 
-
 
   
-  
 
-
-  
-
+
   
 
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 6025054876..19d08686df 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -174,6 +174,7 @@ mymain(void)
 DO_TEST_FAIL_ACTIVE("graphics-vnc-socket-attr-listen-socket-mismatch");
 DO_TEST("graphics-vnc-autoport-no");
 DO_TEST_FAIL_INACTIVE("graphics-listen-network-invalid");
+DO_TEST_DIFFERENT("graphics-listen-network2");

 DO_TEST_FAIL_ACTIVE("name-slash-fail");

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 8cc0874f65..e04001156c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -574,7 +574,6 @@ mymain(void)
 DO_TEST_CAPS_LATEST("disk-scsi-device-auto");
 DO_TEST_CAPS_LATEST("console-virtio");
 DO_TEST_CAPS_LATEST("serial-target-port-auto");
-DO_TEST_CAPS_LATEST("graphics-listen-network2");
 DO_TEST_CAPS_LATEST("numad-auto-vcpu-no-numatune");
 DO_TEST_CAPS_LATEST("numad-auto-memory-vcpu-no-cpuset-and-placement");
 DO_TEST_CAPS_LATEST("numad-auto-memory-vcpu-cpuset");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 06/19] qemuxml2argvtest: Check for duplicate invocation of tests

2023-12-15 Thread Peter Krempa
Prevent duplicated invocation of tests by tracking use of output files.
Some cases need to be exempt from this for now.

Signed-off-by: Peter Krempa 
---
 tests/qemustatusxml2xmltest.c |  2 +-
 tests/qemuxml2argvtest.c  | 37 +++
 tests/testutilsqemu.h |  2 ++
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c
index f1589345c3..4796b62853 100644
--- a/tests/qemustatusxml2xmltest.c
+++ b/tests/qemustatusxml2xmltest.c
@@ -73,7 +73,7 @@ mymain(void)
 {
 int ret = 0;
 g_autoptr(virConnect) conn = NULL;
-struct testQemuConf testConf = { NULL, NULL, NULL };
+struct testQemuConf testConf = { NULL, NULL, NULL, NULL };

 if (qemuTestDriverInit(&driver) < 0)
 return EXIT_FAILURE;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ae4f9f8e0a..a5dce0a2a1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -273,6 +273,7 @@ testCheckExclusiveFlags(int flags)
   FLAG_FIPS_HOST |
   FLAG_REAL_CAPS |
   FLAG_SLIRP_HELPER |
+  FLAG_ALLOW_DUPLICATE_OUTPUT |
   0, -1);

 return 0;
@@ -477,6 +478,28 @@ testCompareXMLToArgvValidateSchema(virCommand *cmd,
 }


+static int
+testInfoCheckDuplicate(struct testQemuInfo *info)
+{
+const char *path = info->outfile;
+
+if (info->flags & FLAG_ALLOW_DUPLICATE_OUTPUT)
+return 0;
+
+if (info->flags & (FLAG_EXPECT_FAILURE | FLAG_EXPECT_PARSE_ERROR))
+path = info->errfile;
+
+if (g_hash_table_contains(info->conf->duplicateTests, path)) {
+fprintf(stderr, "\nduplicate invocation of test case: %s\n'", path);
+return -1;
+}
+
+g_hash_table_insert(info->conf->duplicateTests, g_strdup(path), NULL);
+
+return 0;
+}
+
+
 static int
 testCompareXMLToArgv(const void *data)
 {
@@ -503,6 +526,9 @@ testCompareXMLToArgv(const void *data)
 if (testQemuInfoInitArgs((struct testQemuInfo *) info) < 0)
 goto cleanup;

+if (testInfoCheckDuplicate(info) < 0)
+goto cleanup;
+
 if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
 qemuTestSetHostArch(&driver, info->arch);

@@ -688,12 +714,14 @@ static int
 mymain(void)
 {
 int ret = 0;
+g_autoptr(GHashTable) duplicateTests = virHashNew(NULL);
 g_autoptr(GHashTable) capslatest = testQemuGetLatestCaps();
 g_autoptr(GHashTable) qapiSchemaCache = virHashNew((GDestroyNotify) 
g_hash_table_unref);
 g_autoptr(GHashTable) capscache = virHashNew(virObjectUnref);
 struct testQemuConf testConf = { .capslatest = capslatest,
  .capscache = capscache,
- .qapiSchemaCache = qapiSchemaCache };
+ .qapiSchemaCache = qapiSchemaCache,
+ .duplicateTests = duplicateTests };

 if (!capslatest)
 return EXIT_FAILURE;
@@ -852,7 +880,7 @@ mymain(void)
 DO_TEST_CAPS_ARCH_VER_PARSE_ERROR(name, "x86_64", ver)

 # define DO_TEST_GIC(name, ver, gic) \
-DO_TEST_CAPS_ARCH_VER_FULL(name, "aarch64", ver, ARG_GIC, gic, ARG_END)
+DO_TEST_CAPS_ARCH_VER_FULL(name, "aarch64", ver, ARG_GIC, gic, ARG_FLAGS, 
FLAG_ALLOW_DUPLICATE_OUTPUT, ARG_END)

 /* Unset or set all envvars here that are copied in qemudBuildCommandLine
  * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
@@ -1341,7 +1369,7 @@ mymain(void)
 DO_TEST_CAPS_LATEST("net-vhostuser-multiq");
 DO_TEST_CAPS_LATEST_FAILURE("net-vhostuser-fail");
 DO_TEST_CAPS_LATEST("net-user");
-DO_TEST_CAPS_ARCH_LATEST_FULL("net-user", "x86_64", ARG_FLAGS, 
FLAG_SLIRP_HELPER);
+DO_TEST_CAPS_ARCH_LATEST_FULL("net-user", "x86_64", ARG_FLAGS, 
FLAG_SLIRP_HELPER | FLAG_ALLOW_DUPLICATE_OUTPUT);
 DO_TEST_CAPS_LATEST("net-user-addr");
 DO_TEST_CAPS_LATEST("net-user-passt");
 DO_TEST_CAPS_VER("net-user-passt", "7.2.0");
@@ -1592,7 +1620,8 @@ mymain(void)
   ARG_MIGRATE_FD, 7);
 DO_TEST_CAPS_ARCH_LATEST_FULL("restore-v2-fd", "x86_64",
   ARG_MIGRATE_FROM, "fd:7",
-  ARG_MIGRATE_FD, 7);
+  ARG_MIGRATE_FD, 7,
+  ARG_FLAGS, FLAG_ALLOW_DUPLICATE_OUTPUT);
 DO_TEST_CAPS_ARCH_LATEST_FULL("migrate", "x86_64",
   ARG_MIGRATE_FROM, "tcp:10.0.0.1:5000");
 DO_TEST_CAPS_ARCH_LATEST_FULL("migrate-numa-unaligned", "x86_64",
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index 8dbc480756..71e220de3a 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -62,12 +62,14 @@ typedef enum {
 FLAG_REAL_CAPS  = 1 << 3,
 FLAG_SLIRP_HELPER   = 1 << 4,
 FLAG_SKIP_CONFIG_ACTIVE = 1 << 5, /* Skip 'active' config test in 
qemuxml2xmltes

[PATCH 07/19] qemuxml2argvmock: Mock qemuInterfaceBridgeConnect

2023-12-15 Thread Peter Krempa
Prepare for test cases which would want to call that function.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_interface.h |  2 +-
 tests/qemuxml2argvmock.c  | 17 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h
index 6eed3e6bd7..67cbada36e 100644
--- a/src/qemu/qemu_interface.h
+++ b/src/qemu/qemu_interface.h
@@ -48,7 +48,7 @@ int qemuInterfaceBridgeConnect(virDomainDef *def,
virDomainNetDef *net,
int *tapfd,
size_t *tapfdSize)
-ATTRIBUTE_NONNULL(2);
+ATTRIBUTE_NONNULL(2) G_NO_INLINE;

 int qemuInterfaceOpenVhostNet(virDomainObj *def,
   virDomainNetDef *net) G_NO_INLINE;
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 52c44b2ed0..f2696bd4c3 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -113,6 +113,23 @@ virNetDevTapCreate(char **ifname,
 }
 }

+
+int
+qemuInterfaceBridgeConnect(virDomainDef *def G_GNUC_UNUSED,
+   virQEMUDriver *driver G_GNUC_UNUSED,
+   virDomainNetDef *net G_GNUC_UNUSED,
+   int *tapfd,
+   size_t *tapfdSize)
+{
+size_t i;
+
+for (i = 0; i < *tapfdSize; i++)
+tapfd[i] = STDERR_FILENO + 100 + i;
+
+return 0;
+}
+
+
 int
 virNetDevSetMAC(const char *ifname G_GNUC_UNUSED,
 const virMacAddr *macaddr G_GNUC_UNUSED)
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 04/19] qemuxml2argvdata: Move 'smbios-multiple-type2' case to genericxml2xmltest

2023-12-15 Thread Peter Krempa
The qemu driver explicitly rejects such configuration, thus this is just
a generic XML2XML test case. Move it.

Signed-off-by: Peter Krempa 
---
 .../smbios-multiple-type2.xml   | 0
 tests/genericxml2xmltest.c  | 2 ++
 tests/qemuxml2xmltest.c | 1 -
 3 files changed, 2 insertions(+), 1 deletion(-)
 rename tests/{qemuxml2argvdata => 
genericxml2xmlindata}/smbios-multiple-type2.xml (100%)

diff --git a/tests/qemuxml2argvdata/smbios-multiple-type2.xml 
b/tests/genericxml2xmlindata/smbios-multiple-type2.xml
similarity index 100%
rename from tests/qemuxml2argvdata/smbios-multiple-type2.xml
rename to tests/genericxml2xmlindata/smbios-multiple-type2.xml
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 3cf9bd8159..6025054876 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -216,6 +216,8 @@ mymain(void)
 DO_TEST_FAIL_INACTIVE("memorytune-colliding-allocs");
 DO_TEST_FAIL_INACTIVE("memorytune-colliding-cachetune");

+DO_TEST("smbios-multiple-type2");
+
 DO_TEST("tseg");

 DO_TEST("launch-security-sev");
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 1010b68ebc..8cc0874f65 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -761,7 +761,6 @@ mymain(void)
 DO_TEST_CAPS_LATEST("tap-vhost-incorrect");
 DO_TEST_CAPS_LATEST("shmem-plain-doorbell");
 DO_TEST_CAPS_LATEST("smbios");
-DO_TEST_CAPS_LATEST("smbios-multiple-type2");
 DO_TEST_CAPS_LATEST("smbios-type-fwcfg");

 DO_TEST_CAPS_ARCH_LATEST("aarch64-aavmf-virtio-mmio", "aarch64");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 05/19] qemuxml2argvtest: Remove duplicated invocations of tests

2023-12-15 Thread Peter Krempa
'parallel-tcp-chardev', 'parallel-parport-chardev' are invoked twice
with exactly the same parameters, remove the duplicity.

Signed-off-by: Peter Krempa 
---
 tests/qemuxml2argvtest.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5cef8ca382..ae4f9f8e0a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1408,8 +1408,6 @@ mymain(void)
 DO_TEST_CAPS_LATEST("serial-tcp-tlsx509-secret-chardev");
 VIR_FREE(driver.config->chardevTLSx509secretUUID);
 driver.config->chardevTLS = 0;
-DO_TEST_CAPS_LATEST("parallel-tcp-chardev");
-DO_TEST_CAPS_LATEST("parallel-parport-chardev");
 DO_TEST_CAPS_LATEST("serial-many-chardev");
 DO_TEST_CAPS_LATEST("parallel-tcp-chardev");
 DO_TEST_CAPS_LATEST("parallel-parport-chardev");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 03/19] qemuxml2argvtest: Reinstate 'pseries-vio-address-clash' case

2023-12-15 Thread Peter Krempa
The case was removed in commit 8ff73d22c7405049452e2bf7f281f7460a6b9d10
which modernized the cases without an explicit reason. Reinstate it.

Fixes: 8ff73d22c7405049452e2bf7f281f7460a6b9d10
Signed-off-by: Peter Krempa 
---
 .../qemuxml2argvdata/pseries-vio-address-clash.ppc64-latest.err  | 1 +
 tests/qemuxml2argvtest.c | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/pseries-vio-address-clash.ppc64-latest.err

diff --git a/tests/qemuxml2argvdata/pseries-vio-address-clash.ppc64-latest.err 
b/tests/qemuxml2argvdata/pseries-vio-address-clash.ppc64-latest.err
new file mode 100644
index 00..e4eed76f23
--- /dev/null
+++ b/tests/qemuxml2argvdata/pseries-vio-address-clash.ppc64-latest.err
@@ -0,0 +1 @@
+XML error: spapr-vio address 0x4000 already in use
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 6cb64dba6f..5cef8ca382 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1811,6 +1811,7 @@ mymain(void)

 DO_TEST_CAPS_LATEST_PPC64("pseries-basic");
 DO_TEST_CAPS_LATEST_PPC64("pseries-vio");
+DO_TEST_CAPS_ARCH_LATEST_PARSE_ERROR("pseries-vio-address-clash", "ppc64");
 DO_TEST_CAPS_LATEST_PPC64("pseries-usb-default");
 DO_TEST_CAPS_LATEST_PPC64("pseries-usb-multi");
 DO_TEST_CAPS_LATEST_PPC64("pseries-vio-user-assigned");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 02/19] qemuxml2argvtest: Fix and use 'disk-network-ssh-key' case

2023-12-15 Thread Peter Krempa
The test case was introduced by commit 68599168ea8185689bd227e6d142e3d933558f84
but is only used in the qemunbdkittest. Fix it and make use of it also
in qemuxml2argvtest.

Fixes: 68599168ea8185689bd227e6d142e3d933558f84
Signed-off-by: Peter Krempa 
---
 .../disk-network-ssh-key.x86_64-latest.args   | 38 +++
 .../qemuxml2argvdata/disk-network-ssh-key.xml |  2 +-
 tests/qemuxml2argvtest.c  |  1 +
 3 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 
tests/qemuxml2argvdata/disk-network-ssh-key.x86_64-latest.args

diff --git a/tests/qemuxml2argvdata/disk-network-ssh-key.x86_64-latest.args 
b/tests/qemuxml2argvdata/disk-network-ssh-key.x86_64-latest.args
new file mode 100644
index 00..b8c1e0796f
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-network-ssh-key.x86_64-latest.args
@@ -0,0 +1,38 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}'
 \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel kvm \
+-cpu qemu64 \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device 
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
+-blockdev 
'{"driver":"nbd","server":{"type":"unix","path":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/nbdkit-libvirt-2-storage.socket"},"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"node-name":"libvirt-2-format","read-only":false,"driver":"raw","file":"libvirt-2-storage"}'
 \
+-device 
'{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"libvirt-2-format","id":"virtio-disk0","bootindex":1}'
 \
+-blockdev 
'{"driver":"nbd","server":{"type":"unix","path":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/nbdkit-libvirt-1-storage.socket"},"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}'
 \
+-device 
'{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"libvirt-1-format","id":"virtio-disk1"}'
 \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-sandbox 
on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-network-ssh-key.xml 
b/tests/qemuxml2argvdata/disk-network-ssh-key.xml
index fda01e7e68..6328a9b7ef 100644
--- a/tests/qemuxml2argvdata/disk-network-ssh-key.xml
+++ b/tests/qemuxml2argvdata/disk-network-ssh-key.xml
@@ -33,7 +33,7 @@
 
 
   
-  
+  
 
 
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 94ab5033e7..6cb64dba6f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1190,6 +1190,7 @@ mymain(void)
 DO_TEST_CAPS_LATEST("disk-network-ssh");
 DO_TEST_CAPS_LATEST_NBDKIT("disk-network-ssh-nbdkit", 
QEMU_NBDKIT_CAPS_PLUGIN_SSH);
 DO_TEST_CAPS_LATEST_NBDKIT("disk-network-ssh-password", 
QEMU_NBDKIT_CAPS_PLUGIN_SSH);
+DO_TEST_CAPS_LATEST_NBDKIT("disk-network-ssh-key", 
QEMU_NBDKIT_CAPS_PLUGIN_SSH);
 DO_TEST_CAPS_LATEST("disk-no-boot");
 DO_TEST_CAPS_LATEST("disk-nvme");
 DO_TEST_CAPS_VER("disk-vhostuser-numa", "4.2.0");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 00/19] qemu XML testing improvements, part 1 - forgotten test files and network driver

2023-12-15 Thread Peter Krempa
This patch saga aims to improve and simplify testing of qemu XML
configs.

Part 1 deals with input test files which are not used in
qemuxml2argvtest, introduces a mock network driver and adds a checker
that all input files are in fact used.

Peter Krempa (19):
  qemuxml2argvtest: Reinstate 'console-compat-chardev' and
'pci-serial-dev-chardev'
  qemuxml2argvtest: Fix and use 'disk-network-ssh-key' case
  qemuxml2argvtest: Reinstate 'pseries-vio-address-clash' case
  qemuxml2argvdata: Move 'smbios-multiple-type2' case to
genericxml2xmltest
  qemuxml2argvtest: Remove duplicated invocations of tests
  qemuxml2argvtest: Check for duplicate invocation of tests
  qemuxml2argvmock: Mock qemuInterfaceBridgeConnect
  qemuxml2argvtest: Add test cases covered only by qemuxml2xmltest -
part 1
  qemuxml2xmltest: Move 'graphics-listen-network2' case go
genericxml2xmltest
  qemuxml2*test: Add specific test case for interface link state
  qemuxml*test: Improve 'vhost_queues' test case
  qemuxml2xmltest: Delete 'interface-driver' case
  qemu: process: Separate setup of network device objects
  qemuxml2argvmock: Mock virNetDevSetMTU
  qemuxml2xmltest: Introduce fake network driver
  qemuxml2argvtest: Enable 'graphics-listen-network' case
  virnetworkportxml2xmltest: Add simple versions of bridge/network tests
  qemuxml2argvtest: Add test cases covered only by qemuxml2xmltest -
part 2
  qemuxml2argvtest: Add checker that all input files are used

 src/qemu/qemu_interface.h |   2 +-
 src/qemu/qemu_process.c   |  45 ++--
 src/util/virnetdev.h  |   2 +-
 .../graphics-listen-network2.xml  |   0
 .../smbios-multiple-type2.xml |   0
 .../graphics-listen-network2.xml  |  35 +++
 tests/genericxml2xmltest.c|   3 +
 tests/qemustatusxml2xmltest.c |   2 +-
 ...nu-disable-with-timeout.x86_64-latest.args |  36 +++
 ...hannel-unix-source-path.x86_64-latest.args |  45 
 .../chardev-label.x86_64-latest.args  |  41 +++
 .../console-compat2.x86_64-latest.args|  40 +++
 .../cpu-empty.x86_64-latest.args  |  33 +++
 ...cpu-host-model-features.x86_64-latest.args |  33 +++
 .../cpu-numa-disordered.x86_64-latest.args|  38 +++
 .../disk-active-commit.x86_64-latest.args |  38 +++
 .../disk-mirror-old.x86_64-latest.args|  45 
 .../disk-mirror.x86_64-latest.args|  48 
 .../disk-network-ssh-key.x86_64-latest.args   |  38 +++
 .../qemuxml2argvdata/disk-network-ssh-key.xml |   2 +-
 .../disk-network-vxhs.x86_64-5.0.0.args   |  35 +++
 .../downscript.x86_64-latest.args |  43 +++
 ...graphics-listen-network.x86_64-latest.args |  37 +++
 .../graphics-listen-network.xml   |   2 +-
 .../hostdev-mdev-display.x86_64-latest.args   |  34 +++
 ...ev-scsi-autogen-address.x86_64-latest.args |  60 +
 ...hostdev-scsi-large-unit.x86_64-latest.args |  39 +++
 .../hostdev-scsi-shareable.x86_64-latest.args |  39 +++
 tests/qemuxml2argvdata/interface-driver.xml   |  54 
 .../qemuxml2argvdata/lease.x86_64-latest.args |  39 +++
 .../memorybacking-set.x86_64-latest.args  |  33 +++
 .../memorybacking-unset.x86_64-latest.args|  33 +++
 .../metadata-duplicate.x86_64-latest.args |  36 +++
 .../metadata.x86_64-latest.args   |  36 +++
 .../net-bandwidth.x86_64-latest.args  |  47 
 tests/qemuxml2argvdata/net-bandwidth.xml  |   2 +-
 .../net-bandwidth2.x86_64-latest.args |  44 +++
 tests/qemuxml2argvdata/net-bandwidth2.xml |   2 +-
 .../net-coalesce.x86_64-latest.args   |  48 
 tests/qemuxml2argvdata/net-coalesce.xml   |   6 +-
 .../net-isolated-port.x86_64-latest.args  |  43 +++
 tests/qemuxml2argvdata/net-isolated-port.xml  |   2 +-
 .../net-linkstate.x86_64-latest.args  |  36 +++
 tests/qemuxml2argvdata/net-linkstate.xml  |  34 +++
 .../net-midonet.x86_64-latest.args|  38 +++
 .../net-mtu.x86_64-latest.args|  46 
 tests/qemuxml2argvdata/net-mtu.xml|   4 +-
 .../net-openvswitch.x86_64-latest.args|  38 +++
 tests/qemuxml2argvdata/net-openvswitch.xml|   2 +-
 ...irtio-network-portgroup.x86_64-latest.args |  42 +++
 .../net-virtio-network-portgroup.xml  |   6 +-
 ...-virtio-teaming-network.x86_64-latest.args |  39 +++
 .../net-virtio-teaming-network.xml|   4 +-
 .../net-virtio-vhost.x86_64-latest.args   |  42 +++
 ...{vhost_queues.xml => net-virtio-vhost.xml} |  25 +-
 ...d-auto-vcpu-no-numatune.x86_64-latest.args |  36 +++
 ...static-vcpu-no-numatune.x86_64-latest.args |  36 +++
 ...vcpus-topology-mismatch.x86_64-latest.args |  34 +++
 .../panic-pseries.ppc64-latest.args   |  34 +++
 .../pcihole64-gib.x86_64-latest.args  |  34 +++
 ...pseries-vio-address-clash.ppc64-latest.err |   1 +
 .../s390-defaultconsole.s390x-latest.args |  33 +++
 .../s390-

[PATCH 01/19] qemuxml2argvtest: Reinstate 'console-compat-chardev' and 'pci-serial-dev-chardev'

2023-12-15 Thread Peter Krempa
The tests invocations were accidentaly removed in commit
54257ed51b5132032cedb7e1e7b8c34b9ae52115

Fixes: 54257ed51b5132032cedb7e1e7b8c34b9ae52115
Signed-off-by: Peter Krempa 
---
 tests/qemuxml2argvtest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b2ea2191dc..94ab5033e7 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1413,6 +1413,8 @@ mymain(void)
 DO_TEST_CAPS_LATEST("parallel-tcp-chardev");
 DO_TEST_CAPS_LATEST("parallel-parport-chardev");
 DO_TEST_CAPS_LATEST("parallel-unix-chardev");
+DO_TEST_CAPS_LATEST("console-compat-chardev");
+DO_TEST_CAPS_LATEST("pci-serial-dev-chardev");

 DO_TEST_CAPS_LATEST("channel-guestfwd");
 DO_TEST_CAPS_LATEST("channel-unix-guestfwd");
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 0/4] virsh/virt-admin: Don't use virErrorRestore

2023-12-15 Thread Michal Prívozník
On 12/14/23 17:56, Peter Krempa wrote:
> Client application shouldn't need to reset the error.
> 
> Peter Krempa (4):
>   virshReconnect: Preserve current URI if not explicitly set in
> ctl->connname
>   virshCatchDisconnect: Don't probe connection URI
>   vshAdmConnect: Preserve connection URI in ctl->connname if
> auto-detected
>   vshAdmCatchDisconnect: Don't probe connection URI
> 
>  tools/virsh.c  | 13 +
>  tools/virt-admin.c | 11 ---
>  2 files changed, 9 insertions(+), 15 deletions(-)
> 

Reviewed-by: Michal Privoznik 

which also applies to 4/4 that was send just a minute ago (something
probably ate the original 4/4?).

Michal
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH 4/4] vshAdmCatchDisconnect: Don't probe connection URI

2023-12-15 Thread Peter Krempa
virsh already stores the connection URI in 'ctl->connname', use that
instead.

Signed-off-by: Peter Krempa 
---
 tools/virt-admin.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index 02cf421cee..fa9304c772 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -72,15 +72,10 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUSED,
 {
 vshControl *ctl = opaque;
 const char *str = "unknown reason";
-virErrorPtr error;
-g_autofree char *uri = NULL;

 if (reason == VIR_CONNECT_CLOSE_REASON_CLIENT)
 return;

-virErrorPreserveLast(&error);
-uri = virAdmConnectGetURI(conn);
-
 switch ((virConnectCloseReason) reason) {
 case VIR_CONNECT_CLOSE_REASON_ERROR:
 str = N_("Disconnected from %1$s due to I/O error");
@@ -96,8 +91,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUSED,
 break;
 }

-vshError(ctl, _(str), NULLSTR(uri));
-virErrorRestore(&error);
+vshError(ctl, _(str), NULLSTR(ctl->connname));
 }

 static int
-- 
2.43.0
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH] CIM: Include in libxkutil for malloc functions

2023-12-15 Thread Michal Prívozník
On 12/15/23 11:16, Florian Weimer wrote:
> * Peter Krempa:
> 
>> On Fri, Dec 15, 2023 at 11:04:51 +0100, Florian Weimer wrote:
>>> This avoids implicit function declarations and build failures with
>>> future compilers.
>>>
>>> Not sure where to submit this.  Our Fedora package references
>>> , but it's 404, and I can't find a CIM
>>> component in the Gitlab organization.
>>
>> The libvirt-cim project on gitlab was archived:
>>
>> https://gitlab.com/libvirt/libvirt-cim
>>
>> We can un-archive it if needed so that you can open a merge request.
> 
> If the component is unmaintained upstream, maybe the Fedora package
> should be retired?  I don't really care about the package, I just fixed
> the build failure …

Yep, it's time to retire it in Fedora.

Michal
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread John Levon
On Fri, Dec 15, 2023 at 11:20:10AM +, Daniel P. Berrangé wrote:

> Libvirt is executing the error callback and work done in the error callback
> is breaking our API guarantee.
> 
> This broken API guarantee is not the app's fault, it is libvirt's fault for
> not protecting itself against things the callback might do.
> 
> IOW, should we fix the virDispatchError function, to do the save/restore
> dance either side of invoking the callback. This would aviod exposing any
> new APIs, and make the app should "just work".

This would certainly fix my scenario, yes, thanks.

We still have to deal with the fact that e.g. virDomainFree() cannot be used in
cleanup paths, but the workarounds there are generally not so bad.

regards
john
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread Daniel P . Berrangé
On Wed, Dec 13, 2023 at 11:04:54AM +, John Levon wrote:
> 
> These two functions are currently private to libvirt, hence not available to
> consumers. Would it be possible to make them public? Without them, there's no
> way to do any libvirt call without stomping on an existing error that you may
> want to preserve.
> 
> I have multiple threads sharing a remote connection (to local libvirtd). I 
> need
> to be able to handle connection drops (e.g. libvirtd restart). Long story 
> short,
> the only approach I've found that actually works properly is that there's one
> main conn object, each thread has a virConnectRef() to it, and whenever a 
> thread
> gets an error, we check in the error callback if !virConnectIsAlive(). If so, 
> we
> close the thread's conn, and potentially also clean up the main conn.

I wonder if we should take the position that this behaviour is a libvirt
bug.

We declare that on return from an API call, the last error object reflects
any error that occurred in this API call.

Libvirt is executing the error callback and work done in the error callback
is breaking our API guarantee.

This broken API guarantee is not the app's fault, it is libvirt's fault for
not protecting itself against things the callback might do.

IOW, should we fix the virDispatchError function, to do the save/restore
dance either side of invoking the callback. This would aviod exposing any
new APIs, and make the app should "just work".

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v2 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Fima Shevrin
RPC client implementation uses the following paradigm. The critical
section is organized via virObjectLock(client)/virObjectUnlock(client)
braces. Though this is potentially problematic as
main thread:side thread:
virObjectUnlock(client);
virObjectLock(client);
g_main_loop_quit(client->eventLoop);
virObjectUnlock(client);
g_main_loop_run(client->eventLoop);

This means in particular that is the main thread is executing very long
request like VM migration, the wakeup from the side thread could be
stuck until the main request will be fully completed.

Discrubed case is easily reproducible with the simple python scripts doing slow
and fast requests in parallel from two different threads.

Our idea is to release the lock at the prepare stage and avoid libvirt stuck
during the interaction between main and side threads.

Co-authored-by: Denis V. Lunev 
Co-authored-by: Nikolai Barybin 

Signed-off-by: Fima Shevrin 
---
 src/rpc/virnetclient.c   | 17 -
 src/util/vireventglibwatch.c | 28 ++--
 2 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index de8ebc2da9..63bd42ed3a 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -987,6 +987,9 @@ int virNetClientSetTLSSession(virNetClient *client,
  * etc.  If we make the grade, it will send us a '\1' byte.
  */
 
+/* Here we are not passing the client to virEventGLibAddSocketWatch,
+ * since the entire virNetClientSetTLSSession function requires a lock.
+ */
 source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
 G_IO_IN,
 client->eventCtx,
@@ -1692,14 +1695,18 @@ static int virNetClientIOEventLoop(virNetClient *client,
 if (client->nstreams)
 ev |= G_IO_IN;
 
+/*
+ * We don't need to call virObjectLock(client) here,
+ * since the .prepare function inside glib Main Loop
+ * will do this. virEventGLibAddSocketWatch is responsible
+ * for passing client var in glib .prepare
+ */
 source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
 ev,
 client->eventCtx,
-virNetClientIOEventFD, &data, 
NULL, NULL);
-
-/* Release lock while poll'ing so other threads
- * can stuff themselves on the queue */
-virObjectUnlock(client);
+virNetClientIOEventFD, &data,
+(virObjectLockable *)client,
+NULL);
 
 #ifndef WIN32
 /* Block SIGWINCH from interrupting poll in curses programs,
diff --git a/src/util/vireventglibwatch.c b/src/util/vireventglibwatch.c
index 7680656ba2..641b772995 100644
--- a/src/util/vireventglibwatch.c
+++ b/src/util/vireventglibwatch.c
@@ -34,11 +34,23 @@ struct virEventGLibFDSource {
 
 
 static gboolean
-virEventGLibFDSourcePrepare(GSource *source G_GNUC_UNUSED,
+virEventGLibFDSourcePrepare(GSource *source,
 gint *timeout)
 {
+virEventGLibFDSource *ssource = (virEventGLibFDSource *)source;
 *timeout = -1;
 
+if (ssource->client != NULL)
+virObjectUnlock(ssource->client);
+
+/*
+ * Prepare function may be called multiple times
+ * in glib Main Loop, thus we assign source->client
+ * a null pointer to avoid calling pthread_mutex_unlock
+ * on an already unlocked mutex.
+ * */
+ssource->client = NULL;
+
 return FALSE;
 }
 
@@ -123,11 +135,23 @@ struct virEventGLibSocketSource {
 
 
 static gboolean
-virEventGLibSocketSourcePrepare(GSource *source G_GNUC_UNUSED,
+virEventGLibSocketSourcePrepare(GSource *source,
 gint *timeout)
 {
+virEventGLibSocketSource *ssource = (virEventGLibSocketSource *)source;
 *timeout = -1;
 
+if (ssource->client != NULL)
+virObjectUnlock(ssource->client);
+
+/*
+ * Prepare function may be called multiple times
+ * in glib Main Loop, thus we assign source->client
+ * a null pointer to avoid calling pthread_mutex_unlock
+ * on an already unlocked mutex.
+ * */
+ssource->client = NULL;
+
 return FALSE;
 }
 
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v2 2/3] utils: Module extension for using locable object in GSourceFuncs

2023-12-15 Thread Fima Shevrin
The ability to use virObjectLockable allows to unlock an
object at the prepare stage inside the Main Event Loop.

Co-authored-by: Denis V. Lunev 
Co-authored-by: Nikolai Barybin 

Signed-off-by: Fima Shevrin 
---
 src/rpc/virnetclient.c   |  6 +++---
 src/util/vireventglib.c  |  4 ++--
 src/util/vireventglibwatch.c | 15 ---
 src/util/vireventglibwatch.h |  5 -
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 4ab8af68c5..de8ebc2da9 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -895,7 +895,7 @@ virNetClientTLSHandshake(virNetClient *client)
 source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
 ev,
 client->eventCtx,
-virNetClientIOEventTLS, client, NULL);
+virNetClientIOEventTLS, client, NULL, 
NULL);
 
 return TRUE;
 }
@@ -990,7 +990,7 @@ int virNetClientSetTLSSession(virNetClient *client,
 source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
 G_IO_IN,
 client->eventCtx,
-virNetClientIOEventTLSConfirm, client, 
NULL);
+virNetClientIOEventTLSConfirm, client, 
NULL, NULL);
 
 #ifndef WIN32
 /* Block SIGWINCH from interrupting poll in curses programs */
@@ -1695,7 +1695,7 @@ static int virNetClientIOEventLoop(virNetClient *client,
 source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
 ev,
 client->eventCtx,
-virNetClientIOEventFD, &data, 
NULL);
+virNetClientIOEventFD, &data, 
NULL, NULL);
 
 /* Release lock while poll'ing so other threads
  * can stuff themselves on the queue */
diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c
index 023dc37445..fd348eaa05 100644
--- a/src/util/vireventglib.c
+++ b/src/util/vireventglib.c
@@ -149,7 +149,7 @@ virEventGLibHandleAdd(int fd,
 
 if (events != 0) {
 data->source = virEventGLibAddSocketWatch(
-fd, cond, NULL, virEventGLibHandleDispatch, data, NULL);
+fd, cond, NULL, virEventGLibHandleDispatch, data, NULL, NULL);
 }
 
 g_ptr_array_add(handles, data);
@@ -217,7 +217,7 @@ virEventGLibHandleUpdate(int watch,
 }
 
 data->source = virEventGLibAddSocketWatch(
-data->fd, cond, NULL, virEventGLibHandleDispatch, data, NULL);
+data->fd, cond, NULL, virEventGLibHandleDispatch, data, NULL, 
NULL);
 
 data->events = events;
 VIR_DEBUG("Added new handle source=%p", data->source);
diff --git a/src/util/vireventglibwatch.c b/src/util/vireventglibwatch.c
index b21e505731..7680656ba2 100644
--- a/src/util/vireventglibwatch.c
+++ b/src/util/vireventglibwatch.c
@@ -29,6 +29,7 @@ struct virEventGLibFDSource {
 GPollFD pollfd;
 int fd;
 GIOCondition condition;
+virObjectLockable *client;
 };
 
 
@@ -80,7 +81,8 @@ static GSourceFuncs virEventGLibFDSourceFuncs = {
 
 
 GSource *virEventGLibCreateSocketWatch(int fd,
-   GIOCondition condition)
+   GIOCondition condition,
+   virObjectLockable *client)
 {
 GSource *source;
 virEventGLibFDSource *ssource;
@@ -95,6 +97,8 @@ GSource *virEventGLibCreateSocketWatch(int fd,
 ssource->pollfd.fd = fd;
 ssource->pollfd.events = condition | G_IO_HUP | G_IO_ERR;
 
+ssource->client = client;
+
 g_source_add_poll(source, &ssource->pollfd);
 
 return source;
@@ -114,6 +118,7 @@ struct virEventGLibSocketSource {
 HANDLE event;
 int revents;
 GIOCondition condition;
+virObjectLockable *client;
 };
 
 
@@ -203,7 +208,8 @@ static GSourceFuncs virEventGLibSocketSourceFuncs = {
 
 
 GSource *virEventGLibCreateSocketWatch(int fd,
-   GIOCondition condition)
+   GIOCondition condition,
+   virObjectLockable *client)
 {
 GSource *source;
 virEventGLibSocketSource *ssource;
@@ -221,6 +227,8 @@ GSource *virEventGLibCreateSocketWatch(int fd,
 ssource->pollfd.fd = (gintptr)ssource->event;
 ssource->pollfd.events = G_IO_IN;
 
+ssource->client = client;
+
 WSAEventSelect(ssource->socket, ssource->event,
FD_READ | FD_ACCEPT | FD_CLOSE |
FD_CONNECT | FD_WRITE | FD_OOB);
@@ -239,11 +247,12 @@ virEventGLibAddSocketWatch(int fd,
GMainContext *context,
virEventGLibSocketFunc func,
 

[PATCH v2 0/3] Rework main and side threads interaction in rpc

2023-12-15 Thread Fima Shevrin
From: "Fima Shevrin" 

RPC client implementation uses the following paradigm. The critical
section is organized via virObjectLock(client)/virObjectUnlock(client)
braces. Though this is potentially problematic as
main thread:side thread:
virObjectUnlock(client);
virObjectLock(client);
g_main_loop_quit(client->eventLoop);
virObjectUnlock(client);
g_main_loop_run(client->eventLoop);

This means in particular that is the main thread is executing very long
request like VM migration, the wakeup from the side thread could be
stuck until the main request will be fully completed.

Discrubed case is easily reproducible with the simple python scripts doing slow
and fast requests in parallel from two different threads.

Our idea is to release the lock at the prepare stage and avoid libvirt stuck
during the interaction between main and side threads.

Changes: Add cover letter and versions


From 2d1a5f094101808216970dbf90383ffeadae7fe9 Mon Sep 17 00:00:00 2001
From: "Denis V. Lunev" 
Date: Sat, 25 Nov 2023 14:11:56 +0300
Subject: [PATCH v2 1/3] rpc: mark GSourceFuncs functions in vireventglibwatch.c
 as static

They are not exported from the module and thus should be static.

Signed-off-by: Denis V. Lunev 
Signed-off-by: Fima Shevrin 
---
 src/util/vireventglibwatch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/vireventglibwatch.c b/src/util/vireventglibwatch.c
index b7f3a8786a..b21e505731 100644
--- a/src/util/vireventglibwatch.c
+++ b/src/util/vireventglibwatch.c
@@ -71,7 +71,7 @@ virEventGLibFDSourceFinalize(GSource *source G_GNUC_UNUSED)
 }
 
 
-GSourceFuncs virEventGLibFDSourceFuncs = {
+static GSourceFuncs virEventGLibFDSourceFuncs = {
 .prepare = virEventGLibFDSourcePrepare,
 .check = virEventGLibFDSourceCheck,
 .dispatch = virEventGLibFDSourceDispatch,
@@ -194,7 +194,7 @@ virEventGLibSocketSourceFinalize(GSource *source)
 }
 
 
-GSourceFuncs virEventGLibSocketSourceFuncs = {
+static GSourceFuncs virEventGLibSocketSourceFuncs = {
 .prepare = virEventGLibSocketSourcePrepare,
 .check = virEventGLibSocketSourceCheck,
 .dispatch = virEventGLibSocketSourceDispatch,
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH] Extend libvirt-guests to shutdown only persistent VMs

2023-12-15 Thread Benjamin Taubmann
ping

> On 13. Nov 2023, at 11:22, Benjamin Taubmann  
> wrote:
> 
> At the moment, there is no configuration option for the libvirt-guests
> service that allows users to define that only persistent virtual machines
> should be shutdown on host shutdown.
> 
> Currently, the service config allows to choose between two ON_SHUTDOWN
> actions that are executed on running virtual machines when the host goes
> down: shutdown, suspend.
> The ON_SHUTDOWN action should be orthogonal to the type of the virtual
> machine. However, the existing implementation, does not suspend
> transient virtual machines.
> This is the matrix of actions that is executed on virtual machines based
> on the configured ON_SHUTDOWN action and the type of a virtual machine.
> 
> | persistent | transient
> shutdown | shutdown   | shutdown (what we want to change)
> suspend  | suspend| nothing
> 
> Add config option PERSISTENT_ONLY to libvirt-guests config that allows
> users to define if the ON_SHUTDOWN action should be applied only on
> persistent virtual machines. PERSISTENT_ONLY can be set to true, false,
> default. The default option will implement the already existing logic.
> 
> Case 1: PERSISTENT_ONLY=default
> | persistent | transient
> shutdown | shutdown   | shutdown
> suspend  | suspend| nothing
> 
> Case 2: PERSISTENT_ONLY=true
> | persistent | transient
> shutdown | shutdown   | nothing
> suspend  | suspend| nothing
> 
> Case 3: PERSISTENT_ONLY=false
> | persistent | transient
> shutdown | shutdown   | shutdown
> suspend  | suspend| suspend
> 
> Change-Id: Ib03013d00b3ec60716287dad4743a038cf000763
> ---
> tools/libvirt-guests.sh.in | 37 ++---
> 1 file changed, 30 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
> index 344b54390a..c3c5954e17 100644
> --- a/tools/libvirt-guests.sh.in
> +++ b/tools/libvirt-guests.sh.in
> @@ -38,6 +38,7 @@ PARALLEL_SHUTDOWN=0
> START_DELAY=0
> BYPASS_CACHE=0
> SYNC_TIME=0
> +PERSISTENT_ONLY="default"
> 
> test -f "$initconfdir"/libvirt-guests &&
> . "$initconfdir"/libvirt-guests
> @@ -438,14 +439,16 @@ shutdown_guests_parallel()
> # stop
> # Shutdown or save guests on the configured uris
> stop() {
> -local suspending="true"
> local uri=
> +local action="suspend"
> +local persistent_only="default"
> +
> 
> # last stop was not followed by start
> [ -f "$LISTFILE" ] && return 0
> 
> if [ "x$ON_SHUTDOWN" = xshutdown ]; then
> -suspending="false"
> +action="shutdown"
> if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then
> gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0"
> echo
> @@ -454,6 +457,22 @@ stop() {
> fi
> fi
> 
> +case "x$PERSISTENT_ONLY" in
> +xtrue)
> +persistent_only="true"
> +;;
> +xfalse)
> +persistent_only="false"
> +;;
> +*)
> +if [ "x$action" = xshutdown ]; then
> +persistent_only="false"
> +elif [ "x$action" = xsuspend ]; then
> +persistent_only="true"
> +fi
> +;;
> +esac
> +
> : >"$LISTFILE"
> set -f
> for uri in $URIS; do
> @@ -478,7 +497,7 @@ stop() {
> echo
> fi
> 
> -if "$suspending"; then
> +if "$persistent_only"; then
> local transient="$(list_guests "$uri" "--transient")"
> if [ $? -eq 0 ]; then
> local empty="true"
> @@ -486,7 +505,11 @@ stop() {
> 
> for uuid in $transient; do
> if "$empty"; then
> -eval_gettext "Not suspending transient guests on 
> URI: \$uri: "
> +if [ "x$action" = xsuspend ]; then
> +eval_gettext "Not suspending transient guests on 
> URI: \$uri: "
> +else
> +eval_gettext "Not shutting down transient guests 
> on URI: \$uri: "
> +fi
> empty="false"
> else
> printf ", "
> @@ -520,19 +543,19 @@ stop() {
> 
> if [ -s "$LISTFILE" ]; then
> while read uri list; do
> -if "$suspending"; then
> +if [ "x$action" = xsuspend ]; then
> eval_gettext "Suspending guests on \$uri URI..."; echo
> else
> eval_gettext "Shutting down guests on \$uri URI..."; echo
> fi
> 
> if [ "$PARALLEL_SHUTDOWN" -gt 1 ] &&
> -   ! "$suspending"; then
> +[ "x$action" = xshutdown ]; then
> shutdown_guests_parallel "$uri" "$list"
> else
> local guest=
> for guest in $list; do
> -if "$suspending"; then
> +if [ "x$action" = xsuspend ]; then
> 

Re: [PATCH 3/3] rpc: Rework rpc notifications in main and side thread

2023-12-15 Thread Daniel P . Berrangé
On Fri, Dec 15, 2023 at 02:32:19AM +0800, Fima Shevrin wrote:
> RPC client implementation uses the following paradigm. The critical
> section is organized via virObjectLock(client)/virObjectUnlock(client)
> braces. Though this is potentially problematic as
> main thread:side thread:
> virObjectUnlock(client);
> virObjectLock(client);
> g_main_loop_quit(client->eventLoop);
> virObjectUnlock(client);
> g_main_loop_run(client->eventLoop);
> 
> This means in particular that is the main thread is executing very long
> request like VM migration, the wakeup from the side thread could be
> stuck until the main request will be fully completed.

Can you explain this in more detail, with call traces illustration
for the two threads. You're not saying where the main thread is
doing work with the 'client' lock hold for a long time. Generally
the goal should be for the main thread to only hold the lock for
a short time.  Also if the side thread is already holding a reference
on 'client', then potentially we should consider if it is possible
to terminate the event loop without acquiring the mutex, as GMainLoop
protects itself wrt concurrent usage already, provided all threads
hold a reference directly or indirectly.

> 
> Discrubed case is easily reproducible with the simple python scripts doing 
> slow
> and fast requests in parallel from two different threads.
> 
> Our idea is to release the lock at the prepare stage and avoid libvirt stuck
> during the interaction between main and side threads.
> 
> Co-authored-by: Denis V. Lunev 
> Co-authored-by: Nikolai Barybin 
> 
> Signed-off-by: Fima Shevrin 
> ---
>  src/rpc/virnetclient.c   | 17 -
>  src/util/vireventglibwatch.c | 28 ++--
>  2 files changed, 38 insertions(+), 7 deletions(-)
> 
> diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
> index de8ebc2da9..63bd42ed3a 100644
> --- a/src/rpc/virnetclient.c
> +++ b/src/rpc/virnetclient.c
> @@ -987,6 +987,9 @@ int virNetClientSetTLSSession(virNetClient *client,
>   * etc.  If we make the grade, it will send us a '\1' byte.
>   */
>  
> +/* Here we are not passing the client to virEventGLibAddSocketWatch,
> + * since the entire virNetClientSetTLSSession function requires a lock.
> + */
>  source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
>  G_IO_IN,
>  client->eventCtx,
> @@ -1692,14 +1695,18 @@ static int virNetClientIOEventLoop(virNetClient 
> *client,
>  if (client->nstreams)
>  ev |= G_IO_IN;
>  
> +/*
> + * We don't need to call virObjectLock(client) here,
> + * since the .prepare function inside glib Main Loop
> + * will do this. virEventGLibAddSocketWatch is responsible
> + * for passing client var in glib .prepare
> + */
>  source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock),
>  ev,
>  client->eventCtx,
> -virNetClientIOEventFD, &data, 
> NULL, NULL);
> -
> -/* Release lock while poll'ing so other threads
> - * can stuff themselves on the queue */
> -virObjectUnlock(client);
> +virNetClientIOEventFD, &data,
> +(virObjectLockable *)client,
> +NULL);
>  
>  #ifndef WIN32
>  /* Block SIGWINCH from interrupting poll in curses programs,
> diff --git a/src/util/vireventglibwatch.c b/src/util/vireventglibwatch.c
> index 7680656ba2..641b772995 100644
> --- a/src/util/vireventglibwatch.c
> +++ b/src/util/vireventglibwatch.c
> @@ -34,11 +34,23 @@ struct virEventGLibFDSource {
>  
>  
>  static gboolean
> -virEventGLibFDSourcePrepare(GSource *source G_GNUC_UNUSED,
> +virEventGLibFDSourcePrepare(GSource *source,
>  gint *timeout)
>  {
> +virEventGLibFDSource *ssource = (virEventGLibFDSource *)source;
>  *timeout = -1;
>  
> +if (ssource->client != NULL)
> +virObjectUnlock(ssource->client);
> +
> +/*
> + * Prepare function may be called multiple times
> + * in glib Main Loop, thus we assign source->client
> + * a null pointer to avoid calling pthread_mutex_unlock
> + * on an already unlocked mutex.
> + * */
> +ssource->client = NULL;
> +
>  return FALSE;
>  }
>  
> @@ -123,11 +135,23 @@ struct virEventGLibSocketSource {
>  
>  
>  static gboolean
> -virEventGLibSocketSourcePrepare(GSource *source G_GNUC_UNUSED,
> +virEventGLibSocketSourcePrepare(GSource *source,
>  gint *timeout)
>  {
> +virEventGLibSoc

close callback and multiple threads

2023-12-15 Thread John Levon
On Fri, Dec 15, 2023 at 10:58:29AM +, Daniel P. Berrangé wrote:

> If you use the virConnectRegisterCloseCallback() method, you should get
> notified of the connection drop at precisely the right time, every time,
> regardless of whether you happen to be making an API call at the time.

That only gets called once, not for every thread sharing the connection,
so there is no way to clean up all the other threads.

regards
john
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread Daniel P . Berrangé
On Wed, Dec 13, 2023 at 11:04:54AM +, John Levon wrote:
> 
> These two functions are currently private to libvirt, hence not available to
> consumers. Would it be possible to make them public? Without them, there's no
> way to do any libvirt call without stomping on an existing error that you may
> want to preserve.
> 
> I have multiple threads sharing a remote connection (to local libvirtd). I 
> need
> to be able to handle connection drops (e.g. libvirtd restart). Long story 
> short,
> the only approach I've found that actually works properly is that there's one
> main conn object, each thread has a virConnectRef() to it, and whenever a 
> thread
> gets an error, we check in the error callback if !virConnectIsAlive(). If so, 
> we
> close the thread's conn, and potentially also clean up the main conn.

Is there a real need to call virConnectIsAlive synchronously after every
API error scenario ? That is going to be checking for libvirtd restart
both too frequently, and at the same time, not frequently enough - ie you
don't detect the libvirtd restart until after the next time you make an API
call

If you use the virConnectRegisterCloseCallback() method, you should get
notified of the connection drop at precisely the right time, every time,
regardless of whether you happen to be making an API call at the time.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread Daniel P . Berrangé
On Thu, Dec 14, 2023 at 05:55:41PM +0100, Peter Krempa wrote:
> On Thu, Dec 14, 2023 at 12:03:55 +, John Levon wrote:
> Using the global error handler function is not a very good idea in
> multithreaded applications, so I'd really suggest to have a generic
> handler function that you'll call after receiving a failure code from
> any of the libvirt APIs you care about and that will preserve/raise the
> error in your application.

Right, both virConnSetErrorFunc & virSetErrorFunc are functions
from day 1, that we effectively considered to be redundant once
we retrofitted thread local error reporting into libvirt in the
distant past. Pretty much every all just calls virSetErrorFunc
to disable the silly built-in default print-to-stderr behaviour
we unfortunately have.

> Additionally for handling disconnects libvirt provides a connection
> close callback registrable via virConnectRegisterCloseCallback(), which
> can be registered multiple times with private data for each instance.
> That might help you getting rid of the generic error handler's duty to
> catch disconnects.

OpenStack uses this callback to trigger reconnect when a connection
dies, and I'd consider that good practice. It also executes in clean
stack context direct from the event loop, as opposed to the error
callbacks which can be triggered from completely arbitrary application
code stack context.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread Peter Krempa
On Fri, Dec 15, 2023 at 10:28:18 +, John Levon wrote:
> On Fri, Dec 15, 2023 at 10:32:36AM +0100, Peter Krempa wrote:
> 
> > > Although, it sounds like you know of a counter-example piece of code: is 
> > > it
> > > something you could share?
> > 
> > See above for the pointers to virsh.
> 
> virsh is single threaded.

Yup, I wrote that in the trimmed part of the reply which also shows
example which should work for multi-threaded application.
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread John Levon
On Fri, Dec 15, 2023 at 10:32:36AM +0100, Peter Krempa wrote:

> > Although, it sounds like you know of a counter-example piece of code: is it
> > something you could share?
> 
> See above for the pointers to virsh.

virsh is single threaded.

regards
joh n
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH 1/2] ci: integration: Switch upstream integration tests to Fedora 39

2023-12-15 Thread Andrea Bolognani
On Thu, Dec 14, 2023 at 09:28:16AM +0100, Michal Privoznik wrote:
> Currently, Fedora 37 and 38 is used. The former is now EOL since
> there's new release. Switch 37 to 39 then.
>
> Signed-off-by: Michal Privoznik 
> ---
>  ci/integration.yml | 80 +++---
>  1 file changed, 40 insertions(+), 40 deletions(-)

Patch looks good, but I don't think we can push it until the Fedora
39 runner used for integration tests has been created, and AFAIK
that's a manual process.

Erik, I know that you've taken care of this so far. Has the process
been documented anywhere? Is it something that people other than you
can deal with?

-- 
Andrea Bolognani / Red Hat / Virtualization
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH] CIM: Include in libxkutil for malloc functions

2023-12-15 Thread Florian Weimer
* Peter Krempa:

> On Fri, Dec 15, 2023 at 11:04:51 +0100, Florian Weimer wrote:
>> This avoids implicit function declarations and build failures with
>> future compilers.
>> 
>> Not sure where to submit this.  Our Fedora package references
>> , but it's 404, and I can't find a CIM
>> component in the Gitlab organization.
>
> The libvirt-cim project on gitlab was archived:
>
> https://gitlab.com/libvirt/libvirt-cim
>
> We can un-archive it if needed so that you can open a merge request.

If the component is unmaintained upstream, maybe the Fedora package
should be retired?  I don't really care about the package, I just fixed
the build failure …

Thanks,
Florian
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: [PATCH] CIM: Include in libxkutil for malloc functions

2023-12-15 Thread Peter Krempa
On Fri, Dec 15, 2023 at 11:04:51 +0100, Florian Weimer wrote:
> This avoids implicit function declarations and build failures with
> future compilers.
> 
> Not sure where to submit this.  Our Fedora package references
> , but it's 404, and I can't find a CIM
> component in the Gitlab organization.

The libvirt-cim project on gitlab was archived:

https://gitlab.com/libvirt/libvirt-cim

We can un-archive it if needed so that you can open a merge request.
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH] CIM: Include in libxkutil for malloc functions

2023-12-15 Thread Florian Weimer
This avoids implicit function declarations and build failures with
future compilers.

Not sure where to submit this.  Our Fedora package references
, but it's 404, and I can't find a CIM
component in the Gitlab organization.

Thanks,
Florian

diff --git a/libxkutil/infostore.c b/libxkutil/infostore.c
index d2b2f719dc1d3616..060a83b26e170df7 100644
--- a/libxkutil/infostore.c
+++ b/libxkutil/infostore.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/libxkutil/xml_parse_test.c b/libxkutil/xml_parse_test.c
index 384593d056d07fb2..9af570efc75f7681 100644
--- a/libxkutil/xml_parse_test.c
+++ b/libxkutil/xml_parse_test.c
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 
 
 #include 
 
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


Re: Public virErrorPreserveLast()/virErrorRestore()

2023-12-15 Thread Peter Krempa
On Thu, Dec 14, 2023 at 19:02:56 +, John Levon wrote:
> On Thu, Dec 14, 2023 at 05:55:41PM +0100, Peter Krempa wrote:
> 
> > If you need any form of more complex logic in your application for error
> > reporting (ab)using libvirt's thread local variable to store the error
> 
> I'm a bit lost on the "abuse" claim here.  Is this abuse in your eyes:
> 
> ```
>  int saved_errno = errno;
>  close(fd);
>  errno = saved_errno;
> ```
> 
> since "errno" is libc's thread local variable that stores the error?
> 
> > for other functions in your application will not bring too much
> > simplification of the logic itself.
> 
> Excuse the pseudocode:
> 
> ```
> int func() {
>   ...
>   cleanup:
>   err = virErrorSaveLast(error);
>   virDomainFree(domain);
>   virErrorRestore(error);
>   return ret;
> }
> 
> func2() {
>   ret = func();
>   fprintf(stderr, "%s\n", virGetLastErrorMessage());
> ```


The suggested approach for applications using libvirt is to have their
own virError instance, which is:

1) global (not suited for multithreaded apps, virsh uses this)
2) thread local
3) in a context object

This error instance is then updated only when an error is reported:

A) via the virSetErrorFunc callback (applicable to 1, 2)
B) via a local helper function to store the error after failed libvirt API call

This way, the resetting of the 'last error' object internal to libvirt
will not influence/stomp over the error saved inside the separate error
variable, thus removing the need to actually reset the error.

Option A) is a bit more automatic, as it doesn't require you to be
storing the error after each libvirt call. In case your application
needs to report original error and then invoke some APIs which may fail
to clean up this isn't ideal as you still have the same problem.

Graceful recovery using different code path can be done by simply
clearing the error.

Option B) requires a function call on each cleanup path from a failed
libvirt API but gives you the option to pick specific APIs to report
errors from.

In virsh we use 1) a global error object with A), errors being stored
inside the error callback:

You can have a look at:

 vshErrorHandler, vshResetLibvirtError, and vshReportError

(You'll also find vshSaveLibvirtError, but that is for virsh's usage of
utility code from libvirt which doesn't raise the error via the error
handler. Those helpers are not available from the library)

> versus:
> 
> ```
> int func() {
>   ...
>   cleanup:
>   err = pthread_getspecific(global->pthread_key_libvirt_error);
>   *err = virSaveLastError();
>   virDomainFree(domain);
>   pthread_setspecific(global->pthread_key_libvirt_error, err);
>   return ret;
> }
> 
> func2() {
>   ret = func();
>   err = pthread_getspecific(global->pthread_key_libvirt_error);
>   fprintf(stderr, "%s\n", err->message);
> 
> ```
> 
> If your argument is that the second version is somehow better,

Putting the helpers into a function:

void
yourAppLibvirtErrorReset(void)
{
err = pthread_getspecific(global->pthread_key_libvirt_error);
if (*err)
virERrorFree(*err);
pthread_setspecific(global->pthread_key_libvirt_error, NULL);

}


void
yourAppLibvirtErrorStore(void)
{
if (virGetLastErrorCode() == VIR_ERR_OK)
return;

err = virSaveLastError();
yourAppLibvirtErrorReset();
pthread_setspecific(global->pthread_key_libvirt_error, err);
}


void
yourAppLibvirtErrorReport(void)
{
err = pthread_getspecific(global->pthread_key_libvirt_error);
fprintf(stderr, "%s\n", err->message);
yourAppLibvirtErrorReset();
}

your example then becomes:


```
int func() {
...
cleanup:
yourAppLibvirtErrorStore();
virDomainFree(domain);
return ret;
}

func2() {
ret = func();
yourAppLibvirtErrorReport();

```

Or, if you chose to call yourAppLibvirtErrorStore() from the error
callback:


```
int func() {
...
cleanup:
virDomainFree(domain);
return ret;
}

func2() {
ret = func();
yourAppLibvirtErrorReport();

```

>I don't think
> we're going to agree, and we'll just keep another local patch. Thanks for the
> discussion!
> 
> > Using the global error handler function is not a very good idea in
> > multithreaded applications
> 
> Side note: there's little point in me going into it, but been there, earned 
> the
> scars. Due to, for example, various connection failures showing up as
> VIR_ERR_INTERNAL_ERROR, there's no reliable way to use the close callback with
> multiple threads sharing a connection and correctly differentiating between a
> need to reconnect and an actual API failure.

Could you please elaborate? This sounds like an actual bug we'd want to
fix. The connection close callback is supposed to be reliable because
e.g. migration recovery depends on it.

> 

[PATCH v3 04/13] libxl: turn virCapabilitiesAddHostFeature() to void

2023-12-15 Thread Dmitry Frolov
virCapabilitiesAddHostFeature() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/conf/capabilities.c| 4 +---
 src/conf/capabilities.h| 2 +-
 src/libxl/libxl_capabilities.c | 5 ++---
 src/test/test_driver.c | 6 ++
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 32badee7b3..096ccc18e7 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -276,7 +276,7 @@ virCapsDispose(void *object)
  *
  * Registers a new host CPU feature, eg 'pae', or 'vmx'
  */
-int
+void
 virCapabilitiesAddHostFeature(virCaps *caps,
   const char *name)
 {
@@ -284,8 +284,6 @@ virCapabilitiesAddHostFeature(virCaps *caps,
  caps->host.nfeatures, 1);
 caps->host.features[caps->host.nfeatures] = g_strdup(name);
 caps->host.nfeatures++;
-
-return 0;
 }
 
 /**
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 9eaf6e2807..085c0af868 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -236,7 +236,7 @@ virCapabilitiesHostNUMARef(virCapsHostNUMA *caps);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCapsHostNUMA, virCapabilitiesHostNUMAUnref);
 
-int
+void
 virCapabilitiesAddHostFeature(virCaps *caps,
   const char *name);
 
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 9be64a53a8..836f46341a 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -137,9 +137,8 @@ libxlCapsInitCPU(virCaps *caps, libxl_physinfo *phy_info)
 cpu = virCPUDefNew();
 
 host_pae = phy_info->hw_cap[0] & LIBXL_X86_FEATURE_PAE_MASK;
-if (host_pae &&
-virCapabilitiesAddHostFeature(caps, "pae") < 0)
-return -1;
+if (host_pae)
+virCapabilitiesAddHostFeature(caps, "pae");
 
 host_lm = (phy_info->hw_cap[2] & LIBXL_X86_FEATURE_LM_MASK);
 if (host_lm)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 67f8e75296..ec1a9b75de 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -299,10 +299,8 @@ testBuildCapabilities(virConnectPtr conn)
 if ((caps = virCapabilitiesNew(VIR_ARCH_I686, false, false)) == NULL)
 return NULL;
 
-if (virCapabilitiesAddHostFeature(caps, "pae") < 0)
-return NULL;
-if (virCapabilitiesAddHostFeature(caps, "nonpae") < 0)
-return NULL;
+virCapabilitiesAddHostFeature(caps, "pae");
+virCapabilitiesAddHostFeature(caps, "nonpae");
 
 virCapabilitiesHostInitIOMMU(caps);
 
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 13/13] rpc: turn virNetClientAddProgram() to void

2023-12-15 Thread Dmitry Frolov
virNetClientAddProgram() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/admin/admin_remote.c| 3 +--
 src/locking/lock_driver_lockd.c | 3 +--
 src/logging/log_manager.c   | 3 +--
 src/lxc/lxc_monitor.c   | 4 +---
 src/remote/remote_driver.c  | 7 +++
 src/rpc/virnetclient.c  | 3 +--
 src/rpc/virnetclient.h  | 2 +-
 7 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/admin/admin_remote.c b/src/admin/admin_remote.c
index 3291a1e965..5c4913a76e 100644
--- a/src/admin/admin_remote.c
+++ b/src/admin/admin_remote.c
@@ -214,8 +214,7 @@ remoteAdminPrivNew(const char *sock_path)
  NULL, 0, NULL)))
 goto error;
 
-if (virNetClientAddProgram(priv->client, priv->program) < 0)
-goto error;
+virNetClientAddProgram(priv->client, priv->program);
 
 return priv;
  error:
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index d75302dd0a..0b6c720477 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -213,8 +213,7 @@ static virNetClient 
*virLockManagerLockDaemonConnectionNew(bool privileged,
  NULL)))
 goto error;
 
-if (virNetClientAddProgram(client, *prog) < 0)
-goto error;
+virNetClientAddProgram(client, *prog);
 
 return client;
 
diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c
index d8490f4e5a..19e23d65c5 100644
--- a/src/logging/log_manager.c
+++ b/src/logging/log_manager.c
@@ -88,8 +88,7 @@ virLogManagerConnect(bool privileged,
  NULL)))
 goto error;
 
-if (virNetClientAddProgram(client, *prog) < 0)
-goto error;
+virNetClientAddProgram(client, *prog);
 
 VIR_FREE(daemonPath);
 VIR_FREE(logdpath);
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 811d6685e5..cf2fd1897f 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -169,9 +169,7 @@ virLXCMonitor *virLXCMonitorNew(virDomainObj *vm,
 mon)))
 goto error;
 
-if (virNetClientAddProgram(mon->client,
-   mon->program) < 0)
-goto error;
+virNetClientAddProgram(mon->client, mon->program);
 
 mon->vm = virObjectRef(vm);
 memcpy(&mon->cb, cb, sizeof(mon->cb));
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 132d0194c6..8db638d6cc 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1160,10 +1160,9 @@ doRemoteOpen(virConnectPtr conn,
  conn)))
 goto error;
 
-if (virNetClientAddProgram(priv->client, priv->remoteProgram) < 0 ||
-virNetClientAddProgram(priv->client, priv->lxcProgram) < 0 ||
-virNetClientAddProgram(priv->client, priv->qemuProgram) < 0)
-goto error;
+virNetClientAddProgram(priv->client, priv->remoteProgram);
+virNetClientAddProgram(priv->client, priv->lxcProgram);
+virNetClientAddProgram(priv->client, priv->qemuProgram);
 
 /* Try and authenticate with server */
 VIR_DEBUG("Trying authentication");
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 4ab8af68c5..c5be82abee 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1053,7 +1053,7 @@ bool virNetClientIsOpen(virNetClient *client)
 }
 
 
-int virNetClientAddProgram(virNetClient *client,
+void virNetClientAddProgram(virNetClient *client,
virNetClientProgram *prog)
 {
 virObjectLock(client);
@@ -1062,7 +1062,6 @@ int virNetClientAddProgram(virNetClient *client,
 client->programs[client->nprograms-1] = virObjectRef(prog);
 
 virObjectUnlock(client);
-return 0;
 }
 
 
diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h
index 1647a6cc71..7726b57ef4 100644
--- a/src/rpc/virnetclient.h
+++ b/src/rpc/virnetclient.h
@@ -117,7 +117,7 @@ int virNetClientDupFD(virNetClient *client, bool cloexec);
 
 bool virNetClientHasPassFD(virNetClient *client);
 
-int virNetClientAddProgram(virNetClient *client,
+void virNetClientAddProgram(virNetClient *client,
virNetClientProgram *prog);
 
 int virNetClientAddStream(virNetClient *client,
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 06/13] libxl: turn libxlMakeDomainOSCaps() to void

2023-12-15 Thread Dmitry Frolov
libxlMakeDomainOSCaps() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/libxl/libxl_capabilities.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 8853ba9d88..defbf9d223 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -508,7 +508,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCaps *caps)
 return 0;
 }
 
-static int
+static void
 libxlMakeDomainOSCaps(const char *machine,
   virDomainCapsOS *os,
   virFirmware **firmwares,
@@ -523,7 +523,7 @@ libxlMakeDomainOSCaps(const char *machine,
 capsLoader->readonly.report = true;
 
 if (STREQ(machine, "xenpv") || STREQ(machine, "xenpvh"))
-return 0;
+return;
 
 capsLoader->supported = VIR_TRISTATE_BOOL_YES;
 capsLoader->values.values = g_new0(char *, nfirmwares);
@@ -539,7 +539,7 @@ libxlMakeDomainOSCaps(const char *machine,
 VIR_DOMAIN_CAPS_ENUM_SET(capsLoader->readonly,
  VIR_TRISTATE_BOOL_YES);
 
-return 0;
+return;
 }
 
 static int
@@ -675,8 +675,8 @@ libxlMakeDomainCapabilities(virDomainCaps *domCaps,
 else
 domCaps->maxvcpus = PV_MAX_VCPUS;
 
-if (libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares) < 0 
||
-libxlMakeDomainDeviceDiskCaps(disk) < 0 ||
+libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares);
+if (libxlMakeDomainDeviceDiskCaps(disk) < 0 ||
 libxlMakeDomainDeviceGraphicsCaps(graphics) < 0 ||
 libxlMakeDomainDeviceVideoCaps(video) < 0)
 return -1;
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 09/13] libxl: turn libxlMakeDomainDeviceVideoCaps() to void

2023-12-15 Thread Dmitry Frolov
libxlMakeDomainDeviceVideoCaps() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/libxl/libxl_capabilities.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 9b219adb3c..b0bd468442 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -574,7 +574,7 @@ 
libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphics *dev)
 
 }
 
-static int
+static void
 libxlMakeDomainDeviceVideoCaps(virDomainCapsDeviceVideo *dev)
 {
 dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -584,8 +584,6 @@ libxlMakeDomainDeviceVideoCaps(virDomainCapsDeviceVideo 
*dev)
  VIR_DOMAIN_VIDEO_TYPE_VGA,
  VIR_DOMAIN_VIDEO_TYPE_CIRRUS,
  VIR_DOMAIN_VIDEO_TYPE_XEN);
-
-return 0;
 }
 
 static int
@@ -676,8 +674,8 @@ libxlMakeDomainCapabilities(virDomainCaps *domCaps,
 libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares);
 libxlMakeDomainDeviceDiskCaps(disk);
 libxlMakeDomainDeviceGraphicsCaps(graphics);
-if (libxlMakeDomainDeviceVideoCaps(video) < 0)
-return -1;
+libxlMakeDomainDeviceVideoCaps(video);
+
 if (STRNEQ(domCaps->machine, "xenpvh") &&
 libxlMakeDomainDeviceHostdevCaps(hostdev) < 0)
 return -1;
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 08/13] libxl: turn libxlMakeDomainDeviceGraphicsCaps() to void

2023-12-15 Thread Dmitry Frolov
libxlMakeDomainDeviceGraphicsCaps() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/libxl/libxl_capabilities.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 7663790649..9b219adb3c 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -561,7 +561,7 @@ libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDisk *dev)
 
 }
 
-static int
+static void
 libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphics *dev)
 {
 dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -572,7 +572,6 @@ 
libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphics *dev)
  VIR_DOMAIN_GRAPHICS_TYPE_VNC,
  VIR_DOMAIN_GRAPHICS_TYPE_SPICE);
 
-return 0;
 }
 
 static int
@@ -676,8 +675,8 @@ libxlMakeDomainCapabilities(virDomainCaps *domCaps,
 
 libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares);
 libxlMakeDomainDeviceDiskCaps(disk);
-if (libxlMakeDomainDeviceGraphicsCaps(graphics) < 0 ||
-libxlMakeDomainDeviceVideoCaps(video) < 0)
+libxlMakeDomainDeviceGraphicsCaps(graphics);
+if (libxlMakeDomainDeviceVideoCaps(video) < 0)
 return -1;
 if (STRNEQ(domCaps->machine, "xenpvh") &&
 libxlMakeDomainDeviceHostdevCaps(hostdev) < 0)
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 07/13] libxl: turn libxlMakeDomainDeviceDiskCaps() to void

2023-12-15 Thread Dmitry Frolov
libxlMakeDomainDeviceDiskCaps() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/libxl/libxl_capabilities.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index defbf9d223..7663790649 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -542,7 +542,7 @@ libxlMakeDomainOSCaps(const char *machine,
 return;
 }
 
-static int
+static void
 libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDisk *dev)
 {
 dev->supported = VIR_TRISTATE_BOOL_YES;
@@ -559,7 +559,6 @@ libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDisk *dev)
  VIR_DOMAIN_DISK_BUS_SCSI,
  VIR_DOMAIN_DISK_BUS_XEN);
 
-return 0;
 }
 
 static int
@@ -676,8 +675,8 @@ libxlMakeDomainCapabilities(virDomainCaps *domCaps,
 domCaps->maxvcpus = PV_MAX_VCPUS;
 
 libxlMakeDomainOSCaps(domCaps->machine, os, firmwares, nfirmwares);
-if (libxlMakeDomainDeviceDiskCaps(disk) < 0 ||
-libxlMakeDomainDeviceGraphicsCaps(graphics) < 0 ||
+libxlMakeDomainDeviceDiskCaps(disk);
+if (libxlMakeDomainDeviceGraphicsCaps(graphics) < 0 ||
 libxlMakeDomainDeviceVideoCaps(video) < 0)
 return -1;
 if (STRNEQ(domCaps->machine, "xenpvh") &&
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 02/13] cpu: turn virCPUx86DataAdd() to void

2023-12-15 Thread Dmitry Frolov
virCPUx86DataAdd() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/cpu/cpu_x86.c  | 66 +-
 src/cpu/cpu_x86.h  |  2 +-
 src/libxl/libxl_capabilities.c |  7 +---
 3 files changed, 26 insertions(+), 49 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index f32770b8a3..4f3bfd075b 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2380,8 +2380,8 @@ x86Encode(virArch arch,
 if (!(data_vendor = virCPUDataNew(arch)))
 return -1;
 
-if (v && virCPUx86DataAdd(data_vendor, &v->data) < 0)
-return -1;
+if (v)
+virCPUx86DataAdd(data_vendor, &v->data);
 }
 
 if (forced)
@@ -2455,14 +2455,12 @@ cpuidSetLeaf4(virCPUData *data,
 virCPUx86DataItem item = *subLeaf0;
 virCPUx86CPUID *cpuid = &item.data.cpuid;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 while (cpuid->eax & 0x1f) {
 cpuid->ecx_in++;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 }
 return 0;
 }
@@ -2480,14 +2478,12 @@ cpuidSetLeaf7(virCPUData *data,
 virCPUx86CPUID *cpuid = &item.data.cpuid;
 uint32_t sub;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 for (sub = 1; sub <= subLeaf0->data.cpuid.eax; sub++) {
 cpuid->ecx_in = sub;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 }
 return 0;
 }
@@ -2508,8 +2504,7 @@ cpuidSetLeafB(virCPUData *data,
 virCPUx86CPUID *cpuid = &item.data.cpuid;
 
 while (cpuid->ecx & 0xff00) {
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 cpuid->ecx_in++;
 cpuidCall(cpuid);
 }
@@ -2535,13 +2530,11 @@ cpuidSetLeafD(virCPUData *data,
 virCPUx86CPUID sub1;
 uint32_t sub;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 cpuid->ecx_in = 1;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 
 sub0 = subLeaf0->data.cpuid;
 sub1 = *cpuid;
@@ -2557,8 +2550,7 @@ cpuidSetLeafD(virCPUData *data,
 
 cpuid->ecx_in = sub;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 }
 return 0;
 }
@@ -2582,16 +2574,14 @@ cpuidSetLeafResID(virCPUData *data,
 virCPUx86CPUID *cpuid = &item.data.cpuid;
 uint32_t sub;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 for (sub = 1; sub < 32; sub++) {
 if (!(res & (1U << sub)))
 continue;
 cpuid->ecx_in = sub;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 }
 return 0;
 }
@@ -2614,20 +2604,17 @@ cpuidSetLeaf12(virCPUData *data,
 !(leaf7->data.cpuid.ebx & (1 << 2)))
 return 0;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 cpuid->eax_in = 0x12;
 cpuid->ecx_in = 1;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 
 cpuid->ecx_in = 2;
 cpuidCall(cpuid);
 while (cpuid->eax & 0xf) {
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 cpuid->ecx_in++;
 cpuidCall(cpuid);
 }
@@ -2647,14 +2634,12 @@ cpuidSetLeaf14(virCPUData *data,
 virCPUx86CPUID *cpuid = &item.data.cpuid;
 uint32_t sub;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 for (sub = 1; sub <= subLeaf0->data.cpuid.eax; sub++) {
 cpuid->ecx_in = sub;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 }
 return 0;
 }
@@ -2676,14 +2661,12 @@ cpuidSetLeaf17(virCPUData *data,
 if (subLeaf0->data.cpuid.eax < 3)
 return 0;
 
-if (virCPUx86DataAdd(data, subLeaf0) < 0)
-return -1;
+virCPUx86DataAdd(data, subLeaf0);
 
 for (sub = 1; sub <= subLeaf0->data.cpuid.eax; sub++) {
 cpuid->ecx_in = sub;
 cpuidCall(cpuid);
-if (virCPUx86DataAdd(data, &item) < 0)
-return -1;
+virCPUx86DataAdd(data, &item);
 }
 return 0;
 }
@@ -2728,7 +2711,7 @@ cpuidSet(uint32_t base, virCPUData *data)
 else if (leaf == 0x17)
 rc = cpuidSetLeaf17(data, &item);
 else
-rc = virCPUx86Data

[PATCH v3 10/13] conf: turn virDomainGraphicsListenAppendAddress() to void

2023-12-15 Thread Dmitry Frolov
virDomainGraphicsListenAppendAddress() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/conf/domain_conf.c | 4 +---
 src/conf/domain_conf.h | 4 ++--
 src/libxl/xen_common.c | 7 ++-
 src/libxl/xen_xl.c | 3 +--
 src/vbox/vbox_common.c | 4 +---
 src/vmx/vmx.c  | 3 +--
 6 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22ad43e1d7..7b4d86d837 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29053,7 +29053,7 @@ virDomainGraphicsGetListen(virDomainGraphicsDef *def, 
size_t i)
 }
 
 
-int
+void
 virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def,
  const char *address)
 {
@@ -29064,8 +29064,6 @@ 
virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def,
 glisten.address = g_strdup(address);
 
 VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten);
-
-return 0;
 }
 
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ed07859bc5..1ee33b90a2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3909,8 +3909,8 @@ int virDomainHostdevMatch(virDomainHostdevDef *a,
 
 virDomainGraphicsListenDef *
 virDomainGraphicsGetListen(virDomainGraphicsDef *def, size_t i);
-int virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def,
- const char *address)
+void virDomainGraphicsListenAppendAddress(virDomainGraphicsDef *def,
+  const char *address)
 ATTRIBUTE_NONNULL(1);
 int virDomainGraphicsListenAppendSocket(virDomainGraphicsDef *def,
 const char *socket)
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index d5a0399613..c7bc51b926 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -673,8 +673,7 @@ xenParseVfb(virConf *conf, virDomainDef *def)
 
 if (xenConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0)
 goto cleanup;
-if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0)
-goto cleanup;
+virDomainGraphicsListenAppendAddress(graphics, listenAddr);
 VIR_FREE(listenAddr);
 
 if (xenConfigCopyStringOpt(conf, "vncpasswd", 
&graphics->data.vnc.auth.passwd) < 0)
@@ -766,9 +765,7 @@ xenParseVfb(virConf *conf, virDomainDef *def)
 key = nextkey;
 }
 if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
-if (virDomainGraphicsListenAppendAddress(graphics,
- listenAddr) < 0)
-goto cleanup;
+virDomainGraphicsListenAppendAddress(graphics, listenAddr);
 VIR_FREE(listenAddr);
 }
 def->graphics = g_new0(virDomainGraphicsDef *, 1);
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index f175359307..553aa77896 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -341,8 +341,7 @@ xenParseXLSpice(virConf *conf, virDomainDef *def)
 graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
 if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
 goto cleanup;
-if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0)
-goto cleanup;
+virDomainGraphicsListenAppendAddress(graphics, listenAddr);
 
 if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0)
 goto cleanup;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index de3c9989a5..9f6612ad61 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3625,8 +3625,7 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver 
*data, IMachine *machine)
 if (netAddressUtf8 && STREQ(netAddressUtf8, ""))
 VBOX_UTF8_FREE(netAddressUtf8);
 
-if (virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8) < 0)
-goto cleanup;
+virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8);
 
 gVBoxAPI.UIVRDEServer.GetAllowMultiConnection(VRDEServer, 
&allowMultiConnection);
 if (allowMultiConnection)
@@ -3641,7 +3640,6 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver 
*data, IMachine *machine)
 
 ret = 0;
 
- cleanup:
 VBOX_RELEASE(VRDEServer);
 VBOX_UTF8_FREE(valueTypeUtf8);
 VBOX_UTF8_FREE(netAddressUtf8);
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 26b89776e1..e746ff213b 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -2017,8 +2017,7 @@ virVMXParseVNC(virConf *conf, virDomainGraphicsDef **def)
 goto failure;
 }
 
-if (virDomainGraphicsListenAppendAddress(*def, listenAddr) < 0)
-goto failure;
+virDomainGraphicsListenAppendAddress(*def, listenAddr);
 VIR_FREE(listenAddr);
 
 if (port < 0) {
-- 
2.34.1
___
Devel maili

[PATCH v3 11/13] vbox: turn vboxDumpDisplay() to void

2023-12-15 Thread Dmitry Frolov
vboxDumpDisplay() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/vbox/vbox_common.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 9f6612ad61..305c85f4ec 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3538,7 +3538,7 @@ vboxDumpVideo(virDomainDef *def, struct _vboxDriver *data 
G_GNUC_UNUSED,
 return 0;
 }
 
-static int
+static void
 vboxDumpDisplay(virDomainDef *def, struct _vboxDriver *data, IMachine *machine)
 {
 /* dump display options vrdp/gui/sdl */
@@ -3549,7 +3549,6 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver 
*data, IMachine *machine)
 IVRDEServer *VRDEServer = NULL;
 PRBool VRDxEnabled = PR_FALSE;
 virDomainGraphicsDef *graphics = NULL;
-int ret = -1;
 
 def->ngraphics = 0;
 
@@ -3638,13 +3637,10 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver 
*data, IMachine *machine)
 VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics);
 }
 
-ret = 0;
-
 VBOX_RELEASE(VRDEServer);
 VBOX_UTF8_FREE(valueTypeUtf8);
 VBOX_UTF8_FREE(netAddressUtf8);
 virDomainGraphicsDefFree(graphics);
-return ret;
 }
 
 static int
@@ -4160,8 +4156,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, 
unsigned int flags)
 
 if (vboxDumpVideo(def, data, machine) < 0)
 goto cleanup;
-if (vboxDumpDisplay(def, data, machine) < 0)
-goto cleanup;
+vboxDumpDisplay(def, data, machine);
 if (vboxDumpStorageControllers(def, machine) < 0)
 goto cleanup;
 if (vboxDumpDisks(def, data, machine) < 0)
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 05/13] conf: turn virCapabilitiesSetNetPrefix() to void

2023-12-15 Thread Dmitry Frolov
virCapabilitiesSetNetPrefix() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/conf/capabilities.c| 4 +---
 src/conf/capabilities.h| 2 +-
 src/libxl/libxl_capabilities.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 096ccc18e7..f7e7610ce6 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -312,13 +312,11 @@ virCapabilitiesAddHostMigrateTransport(virCaps *caps,
  *
  * Registers the prefix that is used for generated network interfaces
  */
-int
+void
 virCapabilitiesSetNetPrefix(virCaps *caps,
 const char *prefix)
 {
 caps->host.netprefix = g_strdup(prefix);
-
-return 0;
 }
 
 
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 085c0af868..d770cddd6b 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -244,7 +244,7 @@ int
 virCapabilitiesAddHostMigrateTransport(virCaps *caps,
const char *name);
 
-int
+void
 virCapabilitiesSetNetPrefix(virCaps *caps,
 const char *prefix);
 
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 836f46341a..8853ba9d88 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -179,8 +179,7 @@ libxlCapsInitHost(libxl_ctx *ctx, virCaps *caps)
 if (libxlCapsInitCPU(caps, &phy_info) < 0)
 goto cleanup;
 
-if (virCapabilitiesSetNetPrefix(caps, LIBXL_GENERATED_PREFIX_XEN) < 0)
-goto cleanup;
+virCapabilitiesSetNetPrefix(caps, LIBXL_GENERATED_PREFIX_XEN);
 
 ret = 0;
 
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 01/13] cpu: turn virCPUx86DataAddItem() to void

2023-12-15 Thread Dmitry Frolov
virCPUx86DataAddItem() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/cpu/cpu_x86.c | 27 +++
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 8d0e3947ce..f32770b8a3 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -531,7 +531,7 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *src)
 }
 
 
-static int
+static void
 virCPUx86DataAddItem(virCPUx86Data *data,
  const virCPUx86DataItem *item)
 {
@@ -547,8 +547,6 @@ virCPUx86DataAddItem(virCPUx86Data *data,
   sizeof(virCPUx86DataItem),
   virCPUx86DataSorter, NULL);
 }
-
-return 0;
 }
 
 
@@ -561,10 +559,8 @@ x86DataAdd(virCPUx86Data *data1,
 
 virCPUx86DataIteratorInit(&iter, data2);
 while ((item = virCPUx86DataNext(&iter))) {
-if (virCPUx86DataAddItem(data1, item) < 0)
-return -1;
+virCPUx86DataAddItem(data1, item);
 }
-
 return 0;
 }
 
@@ -819,8 +815,9 @@ x86DataAddSignature(virCPUx86Data *data,
 uint32_t signature)
 {
 virCPUx86DataItem leaf1 = CPUID(.eax_in = 0x1, .eax = signature);
+virCPUx86DataAddItem(data, &leaf1);
 
-return virCPUx86DataAddItem(data, &leaf1);
+return 0;
 }
 
 
@@ -1125,8 +1122,7 @@ x86ParseDataItemList(virCPUx86Data *cpudata,
 }
 }
 
-if (virCPUx86DataAddItem(cpudata, &item) < 0)
-return -1;
+virCPUx86DataAddItem(cpudata, &item);
 ++i;
 
 node = xmlNextElementSibling(node);
@@ -2911,9 +2907,8 @@ virCPUx86Baseline(virCPUDef **cpus,
 return NULL;
 }
 
-if (vendor &&
-virCPUx86DataAddItem(&base_model->data, &vendor->data) < 0)
-return NULL;
+if (vendor)
+virCPUx86DataAddItem(&base_model->data, &vendor->data);
 
 if (x86Decode(cpu, &base_model->data, models,
   (const char **) modelNames, migratable) < 0)
@@ -3172,9 +3167,8 @@ virCPUx86Translate(virCPUDef *cpu,
 if (!(model = x86ModelFromCPU(cpu, map, -1)))
 return -1;
 
-if (model->vendor &&
-virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0)
-return -1;
+if (model->vendor)
+virCPUx86DataAddItem(&model->data, &model->vendor->data);
 
 if (model->signatures && model->signatures->count > 0) {
 virCPUx86Signature *sig = &model->signatures->items[0];
@@ -3302,7 +3296,8 @@ int
 virCPUx86DataAdd(virCPUData *cpuData,
  const virCPUx86DataItem *item)
 {
-return virCPUx86DataAddItem(&cpuData->data.x86, item);
+virCPUx86DataAddItem(&cpuData->data.x86, item);
+return 0;
 }
 
 
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 03/13] libxl: turn libxlCapsAddCPUID() to void

2023-12-15 Thread Dmitry Frolov
libxlCapsAddCPUID() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/libxl/libxl_capabilities.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 9da0fe851c..9be64a53a8 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -55,7 +55,7 @@ struct guest_arch {
 
 #define XEN_CAP_REGEX 
"(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(aarch64|armv7l|x86_32|x86_64|ia64|powerpc64)(p|be)?"
 
-static int
+static void
 libxlCapsAddCPUID(virCPUData *data, virCPUx86CPUID *cpuid, ssize_t ncaps)
 {
 virCPUx86DataItem item = { 0 };
@@ -66,8 +66,6 @@ libxlCapsAddCPUID(virCPUData *data, virCPUx86CPUID *cpuid, 
ssize_t ncaps)
 item.data.cpuid = cpuid[i];
 virCPUx86DataAdd(data, &item);
 }
-
-return 0;
 }
 
 /*
@@ -114,8 +112,7 @@ libxlCapsNodeData(virCPUDef *cpu, libxl_hwcap hwcap)
 return NULL;
 
 ncaps = G_N_ELEMENTS(cpuid);
-if (libxlCapsAddCPUID(cpudata, cpuid, ncaps) < 0)
-return NULL;
+libxlCapsAddCPUID(cpudata, cpuid, ncaps);
 
 return g_steal_pointer(&cpudata);
 }
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 12/13] libxl: turn xenParseXLNamespaceData() to void

2023-12-15 Thread Dmitry Frolov
xenParseXLNamespaceData() always returns 0.

Signed-off-by: Dmitry Frolov 
---
 src/libxl/xen_xl.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index 553aa77896..ea825e85bd 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -1017,7 +1017,7 @@ xenParseXLChannel(virConf *conf, virDomainDef *def)
 return -1;
 }
 
-static int
+static void
 xenParseXLNamespaceData(virConf *conf, virDomainDef *def)
 {
 virConfValue *list = virConfGetValue(conf, "device_model_args");
@@ -1027,7 +1027,7 @@ xenParseXLNamespaceData(virConf *conf, virDomainDef *def)
 size_t n = 0;
 
 if (!list || list->type != VIR_CONF_LIST)
-return 0;
+return;
 
 list = list->list;
 
@@ -1039,7 +1039,7 @@ xenParseXLNamespaceData(virConf *conf, virDomainDef *def)
 }
 
 if (nargs == 0)
-return 0;
+return;
 
 nsdata = g_new0(libxlDomainXmlNsDef, 1);
 def->namespaceData = nsdata;
@@ -1052,8 +1052,6 @@ xenParseXLNamespaceData(virConf *conf, virDomainDef *def)
 
 nsdata->args[n++] = g_strdup(next->str);
 }
-
-return 0;
 }
 
 virDomainDef *
@@ -1104,8 +1102,7 @@ xenParseXL(virConf *conf,
 if (xenParseXLChannel(conf, def) < 0)
 return NULL;
 
-if (xenParseXLNamespaceData(conf, def) < 0)
-return NULL;
+xenParseXLNamespaceData(conf, def);
 
 if (virDomainDefPostParse(def, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
   xmlopt, NULL) < 0)
-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


fixed patch

2023-12-15 Thread Dmitry Frolov
Oops... my fault. libxen-dev package was not installed, so 
xenParseXLNamespaceData
was not compiled, thus i missed the error. Also i missed, that 
libxl_get_physinfo comes with libxen-dev. So, I excluded it from the patch.

Many thanks!
Dmitry.

___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org


[PATCH v3 00/13] Unreacheble code cleanup

2023-12-15 Thread Dmitry Frolov
A lot of unreacheble code was caused by int functions, which return nothing
except zero. Unreacheble code was removed. Corresponding functions type was 
changed to void.
---
v2: Changing functions return type to void
v3: fixed errors in v2

Dmitry Frolov (13):
  cpu: turn virCPUx86DataAddItem() to void
  cpu: turn virCPUx86DataAdd() to void
  libxl: turn libxlCapsAddCPUID() to void
  libxl: turn virCapabilitiesAddHostFeature() to void
  conf: turn virCapabilitiesSetNetPrefix() to void
  libxl: turn libxlMakeDomainOSCaps() to void
  libxl: turn libxlMakeDomainDeviceDiskCaps() to void
  libxl: turn libxlMakeDomainDeviceGraphicsCaps() to void
  libxl: turn libxlMakeDomainDeviceVideoCaps() to void
  conf: turn virDomainGraphicsListenAppendAddress() to void
  vbox: turn vboxDumpDisplay() to void
  libxl: turn xenParseXLNamespaceData() to void
  rpc: turn virNetClientAddProgram() to void

 src/admin/admin_remote.c|  3 +-
 src/conf/capabilities.c |  8 +--
 src/conf/capabilities.h |  4 +-
 src/conf/domain_conf.c  |  4 +-
 src/conf/domain_conf.h  |  4 +-
 src/cpu/cpu_x86.c   | 91 -
 src/cpu/cpu_x86.h   |  2 +-
 src/libxl/libxl_capabilities.c  | 48 ++---
 src/libxl/xen_common.c  |  7 +--
 src/libxl/xen_xl.c  | 14 ++---
 src/locking/lock_driver_lockd.c |  3 +-
 src/logging/log_manager.c   |  3 +-
 src/lxc/lxc_monitor.c   |  4 +-
 src/remote/remote_driver.c  |  7 ++-
 src/rpc/virnetclient.c  |  3 +-
 src/rpc/virnetclient.h  |  2 +-
 src/test/test_driver.c  |  6 +--
 src/vbox/vbox_common.c  | 13 ++---
 src/vmx/vmx.c   |  3 +-
 19 files changed, 81 insertions(+), 148 deletions(-)

-- 
2.34.1
___
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org