[libvirt] [PATCH] qemu: Don't assign alias to disabled balloon device

Jiri Denemark posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/295db6bd4a0a6e9015a9ad8096b6336e9116952e.1521487223.git.jdenemar@redhat.com
Test syntax-check passed
src/qemu/qemu_alias.c                                                 | 3 ++-
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 +---
...muhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 +---
.../qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml                   | 4 +---
...emuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 +---
.../qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml        | 4 +---
.../qemuhotplug-base-ccw-live-with-ccw-virtio.xml                     | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml            | 4 +---
.../qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml   | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml      | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml       | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml    | 4 +---
.../qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell.xml | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain.xml  | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml     | 4 +---
.../qemuhotplug-base-live+watchdog-user-alias.xml                     | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml       | 4 +---
tests/qemuhotplugtestdomains/qemuhotplug-base-live.xml                | 4 +---
.../qemuhotplug-base-with-scsi-controller-live.xml                    | 4 +---
.../qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml     | 4 +---
20 files changed, 21 insertions(+), 58 deletions(-)
[libvirt] [PATCH] qemu: Don't assign alias to disabled balloon device
Posted by Jiri Denemark 6 years ago
<memballoon model='none'/> is the only way to disable balloon driver
since libvirt will add one automatically if the memballoon element is
missing. In other words, there's no balloon device if model is 'none'
and generating an alias for it makes no sense. The alias will be ignored
when parsing the XML and it will disappear once libvirtd is restarted.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_alias.c                                                 | 3 ++-
 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml | 4 +---
 ...muhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml | 4 +---
 .../qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml                   | 4 +---
 ...emuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml | 4 +---
 .../qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml        | 4 +---
 .../qemuhotplug-base-ccw-live-with-ccw-virtio.xml                     | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml            | 4 +---
 .../qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml   | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml      | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml       | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml    | 4 +---
 .../qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell.xml | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain.xml  | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml     | 4 +---
 .../qemuhotplug-base-live+watchdog-user-alias.xml                     | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml       | 4 +---
 tests/qemuhotplugtestdomains/qemuhotplug-base-live.xml                | 4 +---
 .../qemuhotplug-base-with-scsi-controller-live.xml                    | 4 +---
 .../qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml     | 4 +---
 20 files changed, 21 insertions(+), 58 deletions(-)

diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
index d0ca15bae2..95d1e0370a 100644
--- a/src/qemu/qemu_alias.c
+++ b/src/qemu/qemu_alias.c
@@ -612,7 +612,8 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
         if (qemuAssignDeviceWatchdogAlias(def->watchdog) < 0)
             return -1;
     }
-    if (def->memballoon) {
+    if (def->memballoon &&
+        def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
         if (qemuAssingDeviceMemballoonAlias(def->memballoon, 0) < 0)
             return -1;
     }
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
index 75948f324e..f501cde333 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live+ccw-virtio.xml
@@ -50,9 +50,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
index bb9d427c2f..223e929ad5 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio+ccw-virtio-1-reverse.xml
@@ -60,9 +60,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
index c41f5affdd..c745d48558 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-2-ccw-virtio.xml
@@ -50,9 +50,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
index b1114dba9b..3189294b65 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2-explicit.xml
@@ -59,9 +59,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
index b1114dba9b..3189294b65 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio+ccw-virtio-2.xml
@@ -59,9 +59,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml
index 3476f61db5..edf57fcd3f 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live-with-ccw-virtio.xml
@@ -49,9 +49,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml
index 3a202d069e..b97bba78c6 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-ccw-live.xml
@@ -40,9 +40,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <panic model='s390'/>
   </devices>
   <seclabel type='none' model='none'/>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
index 4c3ea3202b..035ec25304 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi-wwn+disk-scsi-duplicate-wwn.xml
@@ -66,9 +66,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml
index 493a615fd3..dd65a48057 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-scsi.xml
@@ -54,9 +54,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml
index 3609819ea3..c161e5b289 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-usb.xml
@@ -54,9 +54,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml
index b88b220e33..299d595d6e 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+disk-virtio.xml
@@ -54,9 +54,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell.xml
index 11ffd9fba8..a6930bfa69 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-doorbell.xml
@@ -44,9 +44,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <shmem name='shmem0'>
       <model type='ivshmem-plain'/>
       <size unit='M'>4</size>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain.xml
index 9736f6bda7..757b6b0980 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+ivshmem-plain.xml
@@ -44,9 +44,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
     <shmem name='shmem0'>
       <model type='ivshmem-plain'/>
       <size unit='M'>4</size>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
index 051273ccf6..b1ba51b2d8 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
@@ -50,9 +50,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog-user-alias.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog-user-alias.xml
index 27aff2b6f8..1fddd68a27 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog-user-alias.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog-user-alias.xml
@@ -48,9 +48,7 @@
       <alias name='ua-UserWatchdog'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </watchdog>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml
index 9f8f983e5d..76b573f25c 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml
@@ -48,9 +48,7 @@
       <alias name='watchdog0'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </watchdog>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live.xml
index 67cf41ad6b..d46e20fa58 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live.xml
@@ -44,9 +44,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-controller-live.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-controller-live.xml
index d23d3d483e..5ee6ea25c3 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-controller-live.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-with-scsi-controller-live.xml
@@ -48,9 +48,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml
index cceb678bb9..d35fea6f5f 100644
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-without-scsi-controller-live+disk-scsi-2.xml
@@ -58,9 +58,7 @@
     <input type='keyboard' bus='ps2'>
       <alias name='input1'/>
     </input>
-    <memballoon model='none'>
-      <alias name='balloon0'/>
-    </memballoon>
+    <memballoon model='none'/>
   </devices>
   <seclabel type='none' model='none'/>
 </domain>
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Don't assign alias to disabled balloon device
Posted by Peter Krempa 6 years ago
On Mon, Mar 19, 2018 at 20:20:23 +0100, Jiri Denemark wrote:
> <memballoon model='none'/> is the only way to disable balloon driver
> since libvirt will add one automatically if the memballoon element is
> missing. In other words, there's no balloon device if model is 'none'
> and generating an alias for it makes no sense. The alias will be ignored
> when parsing the XML and it will disappear once libvirtd is restarted.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list