[libvirt] [PATCH 1/2] qemuDomainUpdateDeviceFlags: Parse device as live if needed

Michal Privoznik posted 2 patches 6 years, 11 months ago
There is a newer version of this series
[libvirt] [PATCH 1/2] qemuDomainUpdateDeviceFlags: Parse device as live if needed
Posted by Michal Privoznik 6 years, 11 months ago
When updating device it's worth parsing live info too as users
might want to update it as well.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_driver.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f0fb806fcd..ab5cc6ea31 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8608,7 +8608,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     int ret = -1;
     virQEMUDriverConfigPtr cfg = NULL;
     virCapsPtr caps = NULL;
-    unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
+    unsigned int parse_flags = 0;
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG |
@@ -8630,15 +8630,19 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;
 
+    if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
+        goto endjob;
+
+    if ((flags & VIR_DOMAIN_AFFECT_CONFIG) &&
+        !(flags & VIR_DOMAIN_AFFECT_LIVE))
+        parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
+
     dev = dev_copy = virDomainDeviceDefParse(xml, vm->def,
                                              caps, driver->xmlopt,
                                              parse_flags);
     if (dev == NULL)
         goto endjob;
 
-    if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
-        goto endjob;
-
     if (flags & VIR_DOMAIN_AFFECT_CONFIG &&
         flags & VIR_DOMAIN_AFFECT_LIVE) {
         /* If we are affecting both CONFIG and LIVE
-- 
2.16.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] qemuDomainUpdateDeviceFlags: Parse device as live if needed
Posted by John Ferlan 6 years, 11 months ago

On 06/12/2018 11:04 AM, Michal Privoznik wrote:
> When updating device it's worth parsing live info too as users
> might want to update it as well.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_driver.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 

So this follows what DetachLiveAndConfig has done with altering
parse_flags to add the inactive mainly because it "makes sense" to
attempt to match whatever "live/active" device may exist to the fullest
possible extent including fields that wouldn't normally be parsed for an
inactive guest.

Took a bit to come to that conclusion ;-) because the commit message
above didn't give me that!

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

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