[PATCH v3 5/9] qemu: add id when build RNG device and rename object id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We didn't set a id when we build RNG device cmdline before.
Give a id to every RNG device and we can hotunplug it via
QMP cmd device_del.

And fix the tests.

Signed-off-by: Luyao Huang <lhuang@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                                      | 12 ++++++------
 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args |  4 ++--
 .../qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args |  4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args     |  4 ++--
 .../qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args |  2 +-
 tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args       |  2 +-
 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args      |  4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args  |  4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-egd.args      |  4 ++--
 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-multiple.args |  8 ++++----
 tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args   |  4 ++--
 11 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c0cd3eb..57f73be 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5780,7 +5780,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
             goto cleanup;
         }
 
-        virBufferAsprintf(&buf, "rng-random,id=%s,filename=%s",
+        virBufferAsprintf(&buf, "rng-random,id=obj%s,filename=%s",
                           dev->info.alias, dev->source.file);
 
         virCommandAddArg(cmd, "-object");
@@ -5803,7 +5803,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
         virCommandAddArgList(cmd, "-chardev", backend, NULL);
 
         virCommandAddArg(cmd, "-object");
-        virCommandAddArgFormat(cmd, "rng-egd,chardev=char%s,id=%s",
+        virCommandAddArgFormat(cmd, "rng-egd,chardev=char%s,id=obj%s",
                                dev->info.alias, dev->info.alias);
         break;
 
@@ -5836,13 +5836,13 @@ qemuBuildRNGDevStr(virDomainDefPtr def,
     }
 
     if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
-        virBufferAsprintf(&buf, "virtio-rng-ccw,rng=%s", dev->info.alias);
+        virBufferAsprintf(&buf, "virtio-rng-ccw,rng=obj%s,id=%s", dev->info.alias, dev->info.alias);
     else if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
-        virBufferAsprintf(&buf, "virtio-rng-s390,rng=%s", dev->info.alias);
+        virBufferAsprintf(&buf, "virtio-rng-s390,rng=obj%s,id=%s", dev->info.alias, dev->info.alias);
     else if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO)
-        virBufferAsprintf(&buf, "virtio-rng-device,rng=%s", dev->info.alias);
+        virBufferAsprintf(&buf, "virtio-rng-device,rng=obj%s,id=%s", dev->info.alias, dev->info.alias);
     else
-        virBufferAsprintf(&buf, "virtio-rng-pci,rng=%s", dev->info.alias);
+        virBufferAsprintf(&buf, "virtio-rng-pci,rng=obj%s,id=%s", dev->info.alias, dev->info.alias);
 
     if (dev->rate > 0) {
         virBufferAsprintf(&buf, ",max-bytes=%u", dev->rate);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
index 05f3629..d12e6e2 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args
@@ -11,5 +11,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -net user,vlan=0,name=hostnet0 -serial pty -chardev pty,id=charconsole1 \
 -device virtconsole,chardev=charconsole1,id=console1 \
 -device virtio-balloon-device,id=balloon0 \
--object rng-random,id=rng0,filename=/dev/random \
--device virtio-rng-device,rng=rng0
+-object rng-random,id=objrng0,filename=/dev/random \
+-device virtio-rng-device,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args
index 62de9d3..dba74e1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args
@@ -10,5 +10,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -net user,vlan=0,name=hostnet0 -serial pty -chardev pty,id=charconsole1 \
 -device virtconsole,chardev=charconsole1,id=console1 \
 -device virtio-balloon-device,id=balloon0 \
--object rng-random,id=rng0,filename=/dev/random \
--device virtio-rng-device,rng=rng0
+-object rng-random,id=objrng0,filename=/dev/random \
+-device virtio-rng-device,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args
index 5206ad8..c73022b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args
@@ -10,5 +10,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -net user,vlan=0,name=hostnet0 -serial pty -chardev pty,id=charconsole1 \
 -device virtconsole,chardev=charconsole1,id=console1 \
 -device virtio-balloon-device,id=balloon0 \
--object rng-random,id=rng0,filename=/dev/random \
--device virtio-rng-device,rng=rng0
+-object rng-random,id=objrng0,filename=/dev/random \
+-device virtio-rng-device,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args
index c09382f..a8a0537 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args
@@ -8,4 +8,4 @@ file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
 -chardev pty,id=charconsole0 \
 -device virtconsole,chardev=charconsole0,id=console0 \
--object rng-random,id=rng0,filename=/dev/hwrng -device virtio-rng-s390,rng=rng0
+-object rng-random,id=objrng0,filename=/dev/hwrng -device virtio-rng-s390,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args
index 6d97156..44ad072 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args
@@ -8,4 +8,4 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
 -chardev pty,id=charconsole0 \
 -device virtconsole,chardev=charconsole0,id=console0 \
--object rng-random,id=rng0,filename=/dev/hwrng -device virtio-rng-s390,rng=rng0
+-object rng-random,id=objrng0,filename=/dev/hwrng -device virtio-rng-s390,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args
index a1b2eb6..3a04ed1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-ccw.args
@@ -10,5 +10,5 @@ id=virtio-disk0,bootindex=1 \
 -chardev pty,id=charconsole0 \
 -device virtconsole,chardev=charconsole0,id=console0 \
 -device virtio-balloon-ccw,id=balloon0,devno=fe.0.000a \
--object rng-random,id=rng0,filename=/dev/hwrng \
--device virtio-rng-ccw,rng=rng0,devno=fe.0.0002
+-object rng-random,id=objrng0,filename=/dev/hwrng \
+-device virtio-rng-ccw,rng=objrng0,id=rng0,devno=fe.0.0002
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
index 58cc473..84aa5cd 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-default.args
@@ -3,5 +3,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -S -M pc -m 214 -smp 1 -nographic -nodefaults \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
--object rng-random,id=rng0,filename=/dev/random \
--device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x7
+-object rng-random,id=objrng0,filename=/dev/random \
+-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x7
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-egd.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-egd.args
index 5530f7d..67c5047 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-egd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-egd.args
@@ -4,5 +4,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
 -chardev socket,id=charrng0,host=1.2.3.4,port=1234 \
--object rng-egd,chardev=charrng0,id=rng0 \
--device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4
+-object rng-egd,chardev=charrng0,id=objrng0 \
+-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-multiple.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-multiple.args
index d1faf09..aa99384 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-multiple.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-multiple.args
@@ -3,8 +3,8 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -M pc -m 214 -smp 1 -nographic -nodefaults \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
--object rng-random,id=rng0,filename=/dev/random \
--device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x7 \
+-object rng-random,id=objrng0,filename=/dev/random \
+-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x7 \
 -chardev socket,id=charrng1,host=1.2.3.4,port=1234 \
--object rng-egd,chardev=charrng1,id=rng1 \
--device virtio-rng-pci,rng=rng1,bus=pci.0,addr=0x4
+-object rng-egd,chardev=charrng1,id=objrng1 \
+-device virtio-rng-pci,rng=objrng1,id=rng1,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
index ecd510e..7fca098 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
@@ -3,5 +3,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -S -M pc -m 214 -smp 1 -nographic -nodefaults \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
--object rng-random,id=rng0,filename=/dev/hwrng \
--device virtio-rng-pci,rng=rng0,max-bytes=123,period=1234,bus=pci.0,addr=0x4
+-object rng-random,id=objrng0,filename=/dev/hwrng \
+-device virtio-rng-pci,rng=objrng0,id=rng0,max-bytes=123,period=1234,bus=pci.0,addr=0x4
-- 
1.8.3.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]