mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
virsh: Pass the correct live/config xml to virshDomainDetachInterface.
cmdDetachInterface function checks for live config flags and then passes the live/config domain xml to virshDomainDetachInterface accordingly. Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
This commit is contained in:
parent
6289cebf40
commit
aaf3ebf760
@ -11292,10 +11292,10 @@ static bool
|
|||||||
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
virDomainPtr dom = NULL;
|
virDomainPtr dom = NULL;
|
||||||
char *doc = NULL;
|
char *doc_live = NULL, *doc_config = NULL;
|
||||||
const char *mac = NULL, *type = NULL;
|
const char *mac = NULL, *type = NULL;
|
||||||
bool ret = false;
|
int flags = 0;
|
||||||
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
|
bool ret = false, affect_config, affect_live;
|
||||||
bool current = vshCommandOptBool(cmd, "current");
|
bool current = vshCommandOptBool(cmd, "current");
|
||||||
bool config = vshCommandOptBool(cmd, "config");
|
bool config = vshCommandOptBool(cmd, "config");
|
||||||
bool live = vshCommandOptBool(cmd, "live");
|
bool live = vshCommandOptBool(cmd, "live");
|
||||||
@ -11306,11 +11306,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
|
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
|
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
|
||||||
|
|
||||||
if (config || persistent)
|
|
||||||
flags |= VIR_DOMAIN_AFFECT_CONFIG;
|
|
||||||
if (live)
|
|
||||||
flags |= VIR_DOMAIN_AFFECT_LIVE;
|
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -11320,20 +11315,31 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (persistent &&
|
affect_config = (config || persistent);
|
||||||
virDomainIsActive(dom) == 1)
|
|
||||||
flags |= VIR_DOMAIN_AFFECT_LIVE;
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
|
if (affect_config) {
|
||||||
doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
|
if (!(doc_config = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE)))
|
||||||
else
|
goto cleanup;
|
||||||
doc = virDomainGetXMLDesc(dom, 0);
|
if (!(ret = virshDomainDetachInterface(doc_config,
|
||||||
|
flags | VIR_DOMAIN_AFFECT_CONFIG,
|
||||||
|
dom, ctl, current, type, mac)))
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!doc)
|
affect_live = (live || (persistent && virDomainIsActive(dom) == 1));
|
||||||
goto cleanup;
|
|
||||||
else
|
if (affect_live || !affect_config) {
|
||||||
ret = virshDomainDetachInterface(doc, flags, dom, ctl,
|
flags = 0;
|
||||||
current, type, mac);
|
|
||||||
|
if (affect_live)
|
||||||
|
flags |= VIR_DOMAIN_AFFECT_LIVE;
|
||||||
|
|
||||||
|
if (!(doc_live = virDomainGetXMLDesc(dom, 0)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = virshDomainDetachInterface(doc_live, flags,
|
||||||
|
dom, ctl, current, type, mac);
|
||||||
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
@ -11341,8 +11347,8 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
} else {
|
} else {
|
||||||
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
|
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
|
||||||
}
|
}
|
||||||
|
VIR_FREE(doc_live);
|
||||||
VIR_FREE(doc);
|
VIR_FREE(doc_config);
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user