On Wed, 2015-11-11 at 10:11 +0300, Nikolay Shirokovskiy wrote: > Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> > --- > src/vz/vz_driver.c | 86 +++++++++++++++++---------------------------------- > 1 files changed, 29 insertions(+), 57 deletions(-) > > diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c > index 7a4d431..3392dc3 100644 > --- a/src/vz/vz_driver.c > +++ b/src/vz/vz_driver.c > @@ -1032,6 +1032,32 @@ vzDomainManagedSaveRemove(virDomainPtr domain, unsigned > int flags) > return ret; > } > > +int vzCheckConfigUpdateFlags(virDomainObjPtr dom, unsigned int flags) > +{ > + if (!(flags & VIR_DOMAIN_AFFECT_CONFIG)) { > + virReportError(VIR_ERR_OPERATION_INVALID, "%s", > + _("domain config update needs VIR_DOMAIN_AFFECT_CONFIG > " > + "flag to be set")); > + return -1; > + } > + > + if (!virDomainObjIsActive(dom) && (flags & VIR_DOMAIN_AFFECT_LIVE)) { > + virReportError(VIR_ERR_OPERATION_INVALID, "%s", > + _("cannot do live update domain config on " > + "inactive domain")); > + return -1; > + } > + > + if (virDomainObjIsActive(dom) && !(flags & VIR_DOMAIN_AFFECT_LIVE)) { > + virReportError(VIR_ERR_OPERATION_INVALID, "%s", > + _("Updates on a running domain need " > + "VIR_DOMAIN_AFFECT_LIVE flag")); > + return -1; > + } > + > + return 0; > +} > + There is a compilation error now: CC vz/libvirt_driver_vz_la-vz_driver.lo vz/vz_driver.c:1035:5: error: no previous prototype for 'vzCheckConfigUpdateFlags' [-Werror=missing-prototypes] int vzCheckConfigUpdateFlags(virDomainObjPtr dom, unsigned int flags) > static int vzDomainAttachDeviceFlags(virDomainPtr dom, const char *xml, > unsigned int flags) > { > @@ -1039,7 +1065,6 @@ static int vzDomainAttachDeviceFlags(virDomainPtr dom, > const char *xml, > vzConnPtr privconn = dom->conn->privateData; > virDomainDeviceDefPtr dev = NULL; > virDomainObjPtr privdom = NULL; > - bool domactive = false; > > virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | > VIR_DOMAIN_AFFECT_CONFIG, -1); > @@ -1047,25 +1072,8 @@ static int vzDomainAttachDeviceFlags(virDomainPtr dom, > const char *xml, > if (!(privdom = vzDomObjFromDomain(dom))) > return -1; > > - if (!(flags & VIR_DOMAIN_AFFECT_CONFIG)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("device attach needs VIR_DOMAIN_AFFECT_CONFIG " > - "flag to be set")); > + if (vzCheckConfigUpdateFlags(privdom, flags) < 0) > goto cleanup; > - } > - > - domactive = virDomainObjIsActive(privdom); > - if (!domactive && (flags & VIR_DOMAIN_AFFECT_LIVE)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("cannot do live update a device on " > - "inactive domain")); > - goto cleanup; > - } > - if (domactive && !(flags & VIR_DOMAIN_AFFECT_LIVE)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("Updates on a running domain need " > - "VIR_DOMAIN_AFFECT_LIVE flag")); > - } > > dev = virDomainDeviceDefParse(xml, privdom->def, privconn->caps, > privconn->xmlopt, VIR_DOMAIN_XML_INACTIVE); > @@ -1115,7 +1123,6 @@ static int vzDomainDetachDeviceFlags(virDomainPtr dom, > const char *xml, > vzConnPtr privconn = dom->conn->privateData; > virDomainDeviceDefPtr dev = NULL; > virDomainObjPtr privdom = NULL; > - bool domactive = false; > > virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | > VIR_DOMAIN_AFFECT_CONFIG, -1); > @@ -1124,25 +1131,8 @@ static int vzDomainDetachDeviceFlags(virDomainPtr dom, > const char *xml, > if (privdom == NULL) > return -1; > > - if (!(flags & VIR_DOMAIN_AFFECT_CONFIG)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("device detach needs VIR_DOMAIN_AFFECT_CONFIG " > - "flag to be set")); > + if (vzCheckConfigUpdateFlags(privdom, flags) < 0) > goto cleanup; > - } > - > - domactive = virDomainObjIsActive(privdom); > - if (!domactive && (flags & VIR_DOMAIN_AFFECT_LIVE)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("cannot do live update a device on " > - "inactive domain")); > - goto cleanup; > - } > - if (domactive && !(flags & VIR_DOMAIN_AFFECT_LIVE)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("Updates on a running domain need " > - "VIR_DOMAIN_AFFECT_LIVE flag")); > - } > > dev = virDomainDeviceDefParse(xml, privdom->def, privconn->caps, > privconn->xmlopt, VIR_DOMAIN_XML_INACTIVE); > @@ -1468,26 +1458,8 @@ static int vzDomainSetMemoryFlags(virDomainPtr domain, > unsigned long memory, > if (!(dom = vzDomObjFromDomain(domain))) > return -1; > > - if (!(flags & VIR_DOMAIN_AFFECT_CONFIG)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("domain config update needs VIR_DOMAIN_AFFECT_CONFIG > " > - "flag to be set")); > - goto cleanup; > - } > - > - if (!virDomainObjIsActive(dom) && (flags & VIR_DOMAIN_AFFECT_LIVE)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("cannot do live update domain config on " > - "inactive domain")); > - goto cleanup; > - } > - > - if (virDomainObjIsActive(dom) && !(flags & VIR_DOMAIN_AFFECT_LIVE)) { > - virReportError(VIR_ERR_OPERATION_INVALID, "%s", > - _("updates on a running domain need " > - "VIR_DOMAIN_AFFECT_LIVE flag")); > + if (vzCheckConfigUpdateFlags(dom, flags) < 0) > goto cleanup; > - } > > ret = vzDomainSetMemoryDefault(dom, memory); > -- Dmitry Guryanov -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list