mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-07 12:17:18 +00:00
adds a new <hostdev managed='(yes|no)'> property to host devices in domains
* docs/schemas/domain.rng src/domain_conf.c src/domain_conf.h src/qemu_conf.c tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.xml tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml: adds a new <hostdev managed='(yes|no)'> property to host devices indicating whether or not we should automatically dettach/reset, patch by Mark McLoughlin daniel
This commit is contained in:
parent
34d23b0b01
commit
09fb8845a7
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
Mon Mar 2 17:35:09 CET 2009 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* docs/schemas/domain.rng src/domain_conf.c src/domain_conf.h
|
||||
src/qemu_conf.c
|
||||
tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address.xml
|
||||
tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.xml
|
||||
tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml:
|
||||
adds a new <hostdev managed='(yes|no)'> property
|
||||
to host devices indicating whether or not we should
|
||||
automatically dettach/reset, patch by Mark McLoughlin
|
||||
|
||||
Mon Mar 2 17:31:48 CET 2009 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/qemu_driver.c: add qemu dettach/reattach/reset implementation
|
||||
|
@ -911,6 +911,12 @@
|
||||
<value>pci</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
<attribute name='managed'>
|
||||
<choice>
|
||||
<value>yes</value>
|
||||
<value>no</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
</optional>
|
||||
<group>
|
||||
<element name='source'>
|
||||
|
@ -1729,7 +1729,7 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
|
||||
|
||||
xmlNodePtr cur;
|
||||
virDomainHostdevDefPtr def;
|
||||
char *mode, *type = NULL;
|
||||
char *mode, *type = NULL, *managed = NULL;
|
||||
|
||||
if (VIR_ALLOC(def) < 0) {
|
||||
virReportOOMError(conn);
|
||||
@ -1761,6 +1761,13 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
|
||||
goto error;
|
||||
}
|
||||
|
||||
managed = virXMLPropString(node, "managed");
|
||||
if (managed != NULL) {
|
||||
if (STREQ(managed, "yes"))
|
||||
def->managed = 1;
|
||||
VIR_FREE(managed);
|
||||
}
|
||||
|
||||
cur = node->children;
|
||||
while (cur != NULL) {
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
@ -3185,7 +3192,8 @@ virDomainHostdevDefFormat(virConnectPtr conn,
|
||||
return -1;
|
||||
}
|
||||
|
||||
virBufferVSprintf(buf, " <hostdev mode='%s' type='%s'>\n", mode, type);
|
||||
virBufferVSprintf(buf, " <hostdev mode='%s' type='%s' managed='%s'>\n",
|
||||
mode, type, def->managed ? "yes" : "no");
|
||||
virBufferAddLit(buf, " <source>\n");
|
||||
|
||||
if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
|
||||
|
@ -305,6 +305,7 @@ typedef struct _virDomainHostdevDef virDomainHostdevDef;
|
||||
typedef virDomainHostdevDef *virDomainHostdevDefPtr;
|
||||
struct _virDomainHostdevDef {
|
||||
int mode; /* enum virDomainHostdevMode */
|
||||
unsigned int managed : 1;
|
||||
union {
|
||||
struct {
|
||||
int type; /* enum virDomainHostdevBusType */
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "datatypes.h"
|
||||
#include "xml.h"
|
||||
#include "nodeinfo.h"
|
||||
#include "pci.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
@ -1394,8 +1395,49 @@ int qemudBuildCommandLine(virConnectPtr conn,
|
||||
ADD_ARG_LIT("-pcidevice");
|
||||
ADD_ARG_LIT(pcidev);
|
||||
VIR_FREE(pcidev);
|
||||
|
||||
if (hostdev->managed) {
|
||||
pciDevice *dev = pciGetDevice(conn,
|
||||
hostdev->source.subsys.u.pci.domain,
|
||||
hostdev->source.subsys.u.pci.bus,
|
||||
hostdev->source.subsys.u.pci.slot,
|
||||
hostdev->source.subsys.u.pci.function);
|
||||
if (!dev)
|
||||
goto error;
|
||||
|
||||
if (pciDettachDevice(conn, dev) < 0) {
|
||||
pciFreeDevice(conn, dev);
|
||||
goto error;
|
||||
}
|
||||
|
||||
pciFreeDevice(conn, dev);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Now that all the PCI hostdevs have be dettached, we can reset them */
|
||||
for (i = 0 ; i < vm->def->nhostdevs ; i++) {
|
||||
virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
|
||||
pciDevice *dev;
|
||||
|
||||
if (!hostdev->managed ||
|
||||
hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
||||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||
continue;
|
||||
|
||||
dev = pciGetDevice(conn,
|
||||
hostdev->source.subsys.u.pci.domain,
|
||||
hostdev->source.subsys.u.pci.bus,
|
||||
hostdev->source.subsys.u.pci.slot,
|
||||
hostdev->source.subsys.u.pci.function);
|
||||
if (!dev)
|
||||
goto error;
|
||||
|
||||
if (pciResetDevice(conn, dev) < 0)
|
||||
goto error;
|
||||
|
||||
pciFreeDevice(conn, dev);
|
||||
}
|
||||
|
||||
if (migrateFrom) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
<source dev='/dev/HostVG/QEMUGuest2'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<hostdev mode='subsystem' type='pci'>
|
||||
<hostdev mode='subsystem' type='pci' managed='no'>
|
||||
<source>
|
||||
<address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
|
||||
</source>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<hostdev mode='subsystem' type='usb'>
|
||||
<hostdev mode='subsystem' type='usb' managed='no'>
|
||||
<source>
|
||||
<address bus='14' device='6'/>
|
||||
</source>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
<target dev='hda' bus='ide'/>
|
||||
</disk>
|
||||
<hostdev mode='subsystem' type='usb'>
|
||||
<hostdev mode='subsystem' type='usb' managed='no'>
|
||||
<source>
|
||||
<vendor id='0x0204'/>
|
||||
<product id='0x6025'/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user