[libvirt] [PATCH v3] Use correct pci addresses during interface-detach
by Nitesh Konkar
From: Nitesh_Konkar <niteshkonkar.libvirt(a)gmail.com>
---
tools/virsh-domain.c | 103 +++++++++++++++++++++++++++++++++------------------
1 file changed, 64 insertions(+), 39 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 979f115..a15ef40 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
-static bool
-cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
+static bool
+vshDomainDetachInterface(char *doc, unsigned int flags, virDomainPtr dom, vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr cur = NULL, matchNode = NULL;
- char *detach_xml = NULL;
const char *mac = NULL, *type = NULL;
- char *doc = NULL;
+ char *detach_xml = NULL;
+ bool current = vshCommandOptBool(cmd, "current");
char buf[64];
int diff_mac;
size_t i;
int ret;
bool functionReturn = false;
- unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
- bool current = vshCommandOptBool(cmd, "current");
- bool config = vshCommandOptBool(cmd, "config");
- bool live = vshCommandOptBool(cmd, "live");
- bool persistent = vshCommandOptBool(cmd, "persistent");
-
- VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
-
- VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
- 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)))
- return false;
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
goto cleanup;
@@ -10859,15 +10823,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
goto cleanup;
- if (persistent &&
- virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_AFFECT_LIVE;
-
- if (flags & VIR_DOMAIN_AFFECT_CONFIG)
- doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
- else
- doc = virDomainGetXMLDesc(dom, 0);
-
if (!doc)
goto cleanup;
@@ -10935,20 +10890,72 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
else
ret = virDomainDetachDevice(dom, detach_xml);
- if (ret != 0) {
- vshError(ctl, "%s", _("Failed to detach interface"));
- } else {
- vshPrint(ctl, "%s", _("Interface detached successfully\n"));
+ if (ret == 0)
functionReturn = true;
- }
cleanup:
- VIR_FREE(doc);
VIR_FREE(detach_xml);
- virDomainFree(dom);
+ xmlFreeDoc(xml);
xmlXPathFreeObject(obj);
xmlXPathFreeContext(ctxt);
- xmlFreeDoc(xml);
+ return functionReturn;
+}
+
+static bool
+cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom = NULL;
+ unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+ char *doc_live = NULL, *doc_config = NULL;
+ bool current = vshCommandOptBool(cmd, "current");
+ bool config = vshCommandOptBool(cmd, "config");
+ bool live = vshCommandOptBool(cmd, "live");
+ bool persistent = vshCommandOptBool(cmd, "persistent");
+ bool functionReturn = false;
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+ if (config || persistent)
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
+
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (persistent &&
+ virDomainIsActive(dom) == 1)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ doc_config = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
+ if (!(functionReturn = vshDomainDetachInterface(doc_config, flags, dom, ctl, cmd)))
+ goto cleanup;
+ }
+
+ if (live || (!live && !config))
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ doc_live = virDomainGetXMLDesc(dom, 0);
+
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG)
+ flags &= (~VIR_DOMAIN_AFFECT_CONFIG);
+
+ functionReturn = vshDomainDetachInterface(doc_live, flags, dom, ctl, cmd);
+ }
+
+ cleanup:
+ if (functionReturn == false) {
+ vshError(ctl, "%s", _("Failed to detach interface"));
+ } else {
+ vshPrint(ctl, "%s", _("Interface detached successfully\n"));
+ functionReturn = true;
+ }
+ VIR_FREE(doc_live);
+ VIR_FREE(doc_config);
+ virDomainFree(dom);
return functionReturn;
}
8 years, 8 months
[libvirt] [PATCH] Use correct pci addresses during interface-detach[v2]
by Nitesh Konkar
The virsh attach virsh detach interface command fails when both live and config
are set and when the interface gets attached to different pci slots
on live and config xml respectively.
When we attach an interface with both --live and --config,
the first time they get the same PCI slots, but the second time
onwards it differs and hence the virsh detach-interface --live
--config command fails. This patch makes sure that when both
--live --config are set , qemuDomainDetachDeviceFlags is called
twice, once with config xml and once with live xml.
Steps to see the issue:
virsh attach-interface --domain DomainName --type network --source default --mac 52:54:00:4b:76:5f --live --config
virsh detach-interface --domain DomainName --type network --mac 52:54:00:4b:76:5f --live --config
virsh attach-interface --domain DomainName --type network --source default --mac 52:54:00:4b:76:5f --live --config
virsh detach-interface --domain DomainName --type network --mac 52:54:00:4b:76:5f --live --config
Signed-off-by:nitkon12@linux.vnet.ibm.com
---
tools/virsh-domain.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 62acecb..43c8436 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10815,7 +10815,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
char buf[64];
int diff_mac;
size_t i;
- int ret;
+ int ret, flag_live_config_both = 0;
bool functionReturn = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
@@ -10830,7 +10830,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (config || persistent)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
- if (live)
+ if (!(config || persistent) && live) // Only Live
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
@@ -10851,6 +10851,8 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
else
doc = virDomainGetXMLDesc(dom, 0);
+ forlivexml:
+
if (!doc)
goto cleanup;
@@ -10921,6 +10923,14 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (ret != 0) {
vshError(ctl, "%s", _("Failed to detach interface"));
} else {
+ if ((config || persistent) && live && flag_live_config_both == 0) {//executed only when live config both in cmd.
+ doc = virDomainGetXMLDesc(dom, 0);
+ flag_live_config_both=1; //Need to execute this code only once
+ flags |= VIR_DOMAIN_AFFECT_LIVE; //set live flag
+ flags &= (~VIR_DOMAIN_AFFECT_CONFIG ); // need to unset config flag as config xml detach is already done.
+ mac=NULL;
+ goto forlivexml;
+ }
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
functionReturn = true;
}
--
1.8.3.1
8 years, 8 months
[libvirt] [PATCH v3] Use correct pci addresses during interface-detach
by Nitesh Konkar
From: Nitesh_Konkar <niteshkonkar.libvirt(a)gmail.com>
---
tools/virsh-domain.c | 103 +++++++++++++++++++++++++++++++++------------------
1 file changed, 64 insertions(+), 39 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 979f115..a15ef40 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
-static bool
-cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
+static bool
+vshDomainDetachInterface(char *doc, unsigned int flags, virDomainPtr dom, vshControl *ctl, const vshCmd *cmd)
{
- virDomainPtr dom = NULL;
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr cur = NULL, matchNode = NULL;
- char *detach_xml = NULL;
const char *mac = NULL, *type = NULL;
- char *doc = NULL;
+ char *detach_xml = NULL;
+ bool current = vshCommandOptBool(cmd, "current");
char buf[64];
int diff_mac;
size_t i;
int ret;
bool functionReturn = false;
- unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
- bool current = vshCommandOptBool(cmd, "current");
- bool config = vshCommandOptBool(cmd, "config");
- bool live = vshCommandOptBool(cmd, "live");
- bool persistent = vshCommandOptBool(cmd, "persistent");
-
- VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
-
- VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
- 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)))
- return false;
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
goto cleanup;
@@ -10859,15 +10823,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
goto cleanup;
- if (persistent &&
- virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_AFFECT_LIVE;
-
- if (flags & VIR_DOMAIN_AFFECT_CONFIG)
- doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
- else
- doc = virDomainGetXMLDesc(dom, 0);
-
if (!doc)
goto cleanup;
@@ -10935,20 +10890,72 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
else
ret = virDomainDetachDevice(dom, detach_xml);
- if (ret != 0) {
- vshError(ctl, "%s", _("Failed to detach interface"));
- } else {
- vshPrint(ctl, "%s", _("Interface detached successfully\n"));
+ if (ret == 0)
functionReturn = true;
- }
cleanup:
- VIR_FREE(doc);
VIR_FREE(detach_xml);
- virDomainFree(dom);
+ xmlFreeDoc(xml);
xmlXPathFreeObject(obj);
xmlXPathFreeContext(ctxt);
- xmlFreeDoc(xml);
+ return functionReturn;
+}
+
+static bool
+cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom = NULL;
+ unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+ char *doc_live = NULL, *doc_config = NULL;
+ bool current = vshCommandOptBool(cmd, "current");
+ bool config = vshCommandOptBool(cmd, "config");
+ bool live = vshCommandOptBool(cmd, "live");
+ bool persistent = vshCommandOptBool(cmd, "persistent");
+ bool functionReturn = false;
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+ if (config || persistent)
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
+
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (persistent &&
+ virDomainIsActive(dom) == 1)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ doc_config = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
+ if (!(functionReturn = vshDomainDetachInterface(doc_config, flags, dom, ctl, cmd)))
+ goto cleanup;
+ }
+
+ if (live || (!live && !config))
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ doc_live = virDomainGetXMLDesc(dom, 0);
+
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG)
+ flags &= (~VIR_DOMAIN_AFFECT_CONFIG);
+
+ functionReturn = vshDomainDetachInterface(doc_live, flags, dom, ctl, cmd);
+ }
+
+ cleanup:
+ if (functionReturn == false) {
+ vshError(ctl, "%s", _("Failed to detach interface"));
+ } else {
+ vshPrint(ctl, "%s", _("Interface detached successfully\n"));
+ functionReturn = true;
+ }
+ VIR_FREE(doc_live);
+ VIR_FREE(doc_config);
+ virDomainFree(dom);
return functionReturn;
}
8 years, 8 months
[libvirt] [PATCH] qemu: Support to detach redirdev device
by Osier Yang
Attaching redirdev device has been supported for a while, but detaching
is not never implemented.
Simple procedure to test:
% lsusb
Bus 001 Device 014: ID 0781:5567 SanDisk Corp. Cruzer Blade
% usbredirserver -p 4000 0781:5567
% virsh attach-device test usb.xml
% cat usb.xml
<redirdev bus='usb' type='tcp'>
<source mode='connect' host='192.168.84.6' service='4000'/>
</redirdev>
% virsh detach-device test usb.xml
% virsh qemu-monitor-command test --pretty '{"execute": "query-chardev"}' | grep 4000
On success, the chardev should not seen in output of above command.
---
src/conf/domain_conf.c | 67 +++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 4 ++
src/libvirt_private.syms | 3 ++
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_hotplug.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_hotplug.h | 3 ++
6 files changed, 176 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3b15cb4..d304232 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13825,6 +13825,73 @@ virDomainMemoryRemove(virDomainDefPtr def,
return ret;
}
+ssize_t
+virDomainRedirdevFind(virDomainDefPtr def,
+ virDomainRedirdevDefPtr redirdev)
+{
+ size_t i;
+
+ for (i = 0; i < def->nredirdevs; i++) {
+ virDomainRedirdevDefPtr tmp = def->redirdevs[i];
+
+ if (redirdev->bus != tmp->bus)
+ continue;
+
+ virDomainChrSourceDef source_chr = redirdev->source.chr;
+ virDomainChrSourceDef tmp_chr = tmp->source.chr;
+
+ if (source_chr.type != tmp_chr.type)
+ continue;
+
+ switch (source_chr.type) {
+ case VIR_DOMAIN_CHR_TYPE_TCP:
+ if (STRNEQ_NULLABLE(source_chr.data.tcp.host,
+ tmp_chr.data.tcp.host))
+ continue;
+ if (STRNEQ_NULLABLE(source_chr.data.tcp.service,
+ tmp_chr.data.tcp.service))
+ continue;
+ if (source_chr.data.tcp.listen != tmp_chr.data.tcp.listen)
+ continue;
+ if (source_chr.data.tcp.protocol != tmp_chr.data.tcp.protocol)
+ continue;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+ if (source_chr.data.spicevmc != tmp_chr.data.spicevmc)
+ continue;
+ break;
+
+ default:
+ /* Unlikely, currently redirdev only supports character device of
+ * type "tcp" and "spicevmc".
+ */
+ break;
+ }
+
+ if (redirdev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ !virDomainDeviceInfoAddressIsEqual(&redirdev->info, &tmp->info))
+ continue;
+
+ break;
+ }
+
+ if (i < def->nredirdevs)
+ return i;
+
+ return -1;
+}
+
+virDomainRedirdevDefPtr
+virDomainRedirdevRemove(virDomainDefPtr def,
+ size_t idx)
+{
+ virDomainRedirdevDefPtr ret = def->redirdevs[idx];
+
+ VIR_DELETE_ELEMENT(def->redirdevs, idx, def->nredirdevs);
+
+ return ret;
+}
char *
virDomainDefGetDefaultEmulator(virDomainDefPtr def,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1de3be3..03c0155 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2538,6 +2538,10 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
void virDomainHubDefFree(virDomainHubDefPtr def);
void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
+ssize_t virDomainRedirdevFind(virDomainDefPtr def,
+ virDomainRedirdevDefPtr redirdev);
+virDomainRedirdevDefPtr virDomainRedirdevRemove(virDomainDefPtr def,
+ size_t idx);
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
void virDomainShmemDefFree(virDomainShmemDefPtr def);
void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 4b40612..ad7d82c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -423,6 +423,9 @@ virDomainPMSuspendedReasonTypeFromString;
virDomainPMSuspendedReasonTypeToString;
virDomainRedirdevBusTypeFromString;
virDomainRedirdevBusTypeToString;
+virDomainRedirdevDefFree;
+virDomainRedirdevFind;
+virDomainRedirdevRemove;
virDomainRNGBackendTypeToString;
virDomainRNGDefFree;
virDomainRNGFind;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 45ff3c0..8905af6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7736,6 +7736,9 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_MEMORY:
ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory);
break;
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ ret = qemuDomainDetachRedirdevDevice(driver, vm, dev->data.redirdev);
+ break;
case VIR_DOMAIN_DEVICE_FS:
case VIR_DOMAIN_DEVICE_INPUT:
@@ -7748,7 +7751,6 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_SHMEM:
- case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index dc76268..bbe8aa7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3287,6 +3287,49 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
}
+static int
+qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainRedirdevDefPtr redirdev)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virObjectEventPtr event;
+ char *charAlias = NULL;
+ ssize_t idx;
+ int rc;
+ int ret = -1;
+
+ VIR_DEBUG("Removing redirdev device %s from domain %p %s",
+ redirdev->info.alias, vm, vm->def->name);
+
+ if (virAsprintf(&charAlias, "char%s", redirdev->info.alias) < 0)
+ return -1;
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ goto cleanup;
+
+ virDomainAuditRedirdev(vm, redirdev, "detach", rc == 0);
+
+ if (rc < 0)
+ goto cleanup;
+
+ event = virDomainEventDeviceRemovedNewFromObj(vm, redirdev->info.alias);
+ qemuDomainEventQueue(driver, event);
+
+ if ((idx = virDomainRedirdevFind(vm->def, redirdev)) >= 0)
+ virDomainRedirdevRemove(vm->def, idx);
+ qemuDomainReleaseDeviceAddress(vm, &redirdev->info, NULL);
+ virDomainRedirdevDefFree(redirdev);
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(charAlias);
+ return ret;
+}
+
int
qemuDomainRemoveDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
@@ -3318,6 +3361,10 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
ret = qemuDomainRemoveMemoryDevice(driver, vm, dev->data.memory);
break;
+ case VIR_DOMAIN_DEVICE_REDIRDEV:
+ ret = qemuDomainRemoveRedirdevDevice(driver, vm, dev->data.redirdev);
+ break;
+
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_FS:
@@ -3327,7 +3374,6 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_DEVICE_WATCHDOG:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB:
- case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
case VIR_DOMAIN_DEVICE_NVRAM:
@@ -4318,3 +4364,52 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
qemuDomainResetDeviceRemoval(vm);
return ret;
}
+
+int
+qemuDomainDetachRedirdevDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainRedirdevDefPtr redirdev)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virDomainRedirdevDefPtr tmp;
+ ssize_t idx;
+ int rc;
+ int ret = -1;
+
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("qemu does not support -device"));
+ return -1;
+ }
+
+ if ((idx = virDomainRedirdevFind(vm->def, redirdev)) < 0) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("device not present in domain configuration"));
+ return -1;
+ }
+
+ tmp = vm->def->redirdevs[idx];
+
+ if (!tmp->info.alias) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("alias not set for redirdev device"));
+ return -1;
+ }
+
+ qemuDomainMarkDeviceForRemoval(vm, &tmp->info);
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ rc = qemuMonitorDelDevice(priv->mon, tmp->info.alias);
+ if (qemuDomainObjExitMonitor(driver, vm) || rc < 0)
+ goto cleanup;
+
+ rc = qemuDomainWaitForDeviceRemoval(vm);
+ if (rc == 0 || rc == 1)
+ ret = qemuDomainRemoveRedirdevDevice(driver, vm, tmp);
+ else
+ ret = 0;
+
+ cleanup:
+ qemuDomainResetDeviceRemoval(vm);
+ return ret;
+}
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index 4140da3..4ef42e9 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -51,6 +51,9 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainRedirdevDefPtr hostdev);
+int qemuDomainDetachRedirdevDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainRedirdevDefPtr redirdev);
int qemuDomainAttachHostDevice(virConnectPtr conn,
virQEMUDriverPtr driver,
virDomainObjPtr vm,
--
2.1.4
8 years, 8 months
[libvirt] [PATCH 0/3] vz: disk format support
by Mikhail Feoktistov
Mikhail Feoktistov (3):
vz: add vzInitVersion function
vz: add virStorageFileFormat to connection structure
vz: check supported disk format
src/vz/vz_driver.c | 52 +++++++-----------------------------------
src/vz/vz_sdk.c | 28 ++++++++++++++++-------
src/vz/vz_sdk.h | 2 +-
src/vz/vz_utils.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/vz/vz_utils.h | 10 +++++++++
5 files changed, 105 insertions(+), 53 deletions(-)
--
1.8.3.1
8 years, 8 months
[libvirt] [PATCH] virLXCProcessMonitorInitNotify: Initialize @inode
by Michal Privoznik
This is an error message I've just seen. Fix it by initializing
@inode.
CC lxc/libvirt_driver_lxc_impl_la-lxc_process.lo
lxc/lxc_process.c: In function 'virLXCProcessMonitorInitNotify':
lxc/lxc_process.c:767:23: error: 'inode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
virDomainAuditInit(vm, initpid, inode);
^
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial rule.
src/lxc/lxc_process.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 50bee48..5e0bbe2 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -749,7 +749,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
virLXCDriverPtr driver = lxc_driver;
virLXCDomainObjPrivatePtr priv;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
- ino_t inode;
+ ino_t inode = 0;
virObjectLock(vm);
@@ -762,7 +762,6 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
(unsigned long long)initpid,
err && err->message ? err->message : "<unknown>");
virResetLastError();
- inode = 0;
}
virDomainAuditInit(vm, initpid, inode);
--
2.4.10
8 years, 8 months
[libvirt] [PATCH v3 0/2] cleanup resolving persistent/running/current flags
by Nikolay Shirokovskiy
Changes from version2
=====================
1. Already ACKed or PUSHed patches are dropped.
2. Patch of reusing virDomainObjUpdateModificationImpact is splitted
into lxc and libxl and compilation is fixed.
Nikolay Shirokovskiy (2):
lxc: reuse virDomainObjUpdateModificationImpact
libxl: reuse virDomainObjUpdateModificationImpact
src/libxl/libxl_driver.c | 63 ++++------------------------------------
src/lxc/lxc_driver.c | 75 ++++--------------------------------------------
2 files changed, 12 insertions(+), 126 deletions(-)
--
1.8.3.1
8 years, 8 months
[libvirt] [PATCH] tools: do not leak uri in disconnect handler
by Ján Tomko
Commit 035947e introduced a call to virConnectGetURI
without a matching free() in virshCatchDisconnect.
Also fix vshAdmCatchDisconnect where it was copied by
commit 6dd7e42.
https://bugzilla.redhat.com/show_bug.cgi?id=1303891
---
tools/virsh.c | 1 +
tools/virt-admin.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/virsh.c b/tools/virsh.c
index 72446be..57b4ff3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -124,6 +124,7 @@ virshCatchDisconnect(virConnectPtr conn,
break;
}
vshError(ctl, _(str), NULLSTR(uri));
+ VIR_FREE(uri);
if (error) {
virSetError(error);
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index 3c818a3..c470536 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -92,6 +92,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn ATTRIBUTE_UNUSED,
}
vshError(ctl, _(str), NULLSTR(uri));
+ VIR_FREE(uri);
if (error) {
virSetError(error);
--
2.4.10
8 years, 8 months