[libvirt] [PATCH v2 11/12] qemu: Implement virDomainDetachDeviceAlias
Ján Tomko
jtomko at redhat.com
Sat May 26 17:35:09 UTC 2018
On Thu, May 24, 2018 at 01:13:38PM +0200, Michal Privoznik wrote:
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> src/qemu/qemu_driver.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 108 insertions(+)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index 81a9833b39..6f0a3d0cda 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -8750,6 +8750,77 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver,
> return ret;
> }
>
>+
>+static int
>+qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
>+ virDomainObjPtr vm,
>+ const char *alias,
>+ unsigned int flags)
>+{
>+ virCapsPtr caps = NULL;
>+ virQEMUDriverConfigPtr cfg = NULL;
>+ virDomainDefPtr def = NULL;
>+ virDomainDefPtr persistentDef = NULL;
>+ virDomainDefPtr vmdef = NULL;
>+ unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
Why on earth would we need parse_flags to detach a device?
>+ int ret = -1;
>+
>+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
>+ VIR_DOMAIN_AFFECT_CONFIG, -1);
>+
>+ if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
>+ goto cleanup;
>+
>+ cfg = virQEMUDriverGetConfig(driver);
>+
>+ if ((flags & VIR_DOMAIN_AFFECT_CONFIG) &&
>+ !(flags & VIR_DOMAIN_AFFECT_LIVE))
>+ parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
>+
>+ if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
>+ goto cleanup;
>+
>+ if (persistentDef) {
>+ virDomainDeviceDef dev;
>+
>+ vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt);
>+ if (!vmdef)
>+ goto cleanup;
>+
>+ if (virDomainDefFindDevice(persistentDef, alias, &dev, true) < 0)
>+ goto cleanup;
>+
>+ if (qemuDomainDetachDeviceConfig(persistentDef, &dev, caps,
>+ parse_flags, driver->xmlopt) < 0)
Oh, somebody thought it would be a good idea to call postParse even
though no parsing has happened....
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180526/f41a04dd/attachment-0001.sig>
More information about the libvir-list
mailing list