mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Convert monitor over to use virDomainDeviceAddress
Convert the QEMU monitor APIs over to use virDomainDeviceAddress structs for passing addresses in/out, instead of individual bits. This makes the number of parameters smaller & easier to deal with. No functional change * src/qemu/qemu_driver.c, src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Change monitor hotplug APIs to take an explicit address ptr for all host/guest addresses
This commit is contained in:
parent
8d6af63a8a
commit
ab0da52b43
@ -5093,6 +5093,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
|
|||||||
int i, ret;
|
int i, ret;
|
||||||
const char* type = virDomainDiskBusTypeToString(dev->data.disk->bus);
|
const char* type = virDomainDiskBusTypeToString(dev->data.disk->bus);
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
virDomainDevicePCIAddress guestAddr;
|
||||||
|
|
||||||
for (i = 0 ; i < vm->def->ndisks ; i++) {
|
for (i = 0 ; i < vm->def->ndisks ; i++) {
|
||||||
if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) {
|
if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) {
|
||||||
@ -5111,13 +5112,12 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
|
|||||||
ret = qemuMonitorAddPCIDisk(priv->mon,
|
ret = qemuMonitorAddPCIDisk(priv->mon,
|
||||||
dev->data.disk->src,
|
dev->data.disk->src,
|
||||||
type,
|
type,
|
||||||
&dev->data.disk->info.addr.pci.domain,
|
&guestAddr);
|
||||||
&dev->data.disk->info.addr.pci.bus,
|
|
||||||
&dev->data.disk->info.addr.pci.slot);
|
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
dev->data.disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
dev->data.disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
||||||
|
memcpy(&dev->data.disk->info.addr.pci, &guestAddr, sizeof(guestAddr));
|
||||||
virDomainDiskInsertPreAlloced(vm->def, dev->data.disk);
|
virDomainDiskInsertPreAlloced(vm->def, dev->data.disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5174,6 +5174,7 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
|
|||||||
char *nicstr = NULL;
|
char *nicstr = NULL;
|
||||||
char *netstr = NULL;
|
char *netstr = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
virDomainDevicePCIAddress guestAddr;
|
||||||
|
|
||||||
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HOST_NET_ADD)) {
|
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HOST_NET_ADD)) {
|
||||||
qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, "%s",
|
qemudReportError(conn, dom, NULL, VIR_ERR_NO_SUPPORT, "%s",
|
||||||
@ -5242,13 +5243,12 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
|
if (qemuMonitorAddPCINetwork(priv->mon, nicstr,
|
||||||
&net->info.addr.pci.domain,
|
&guestAddr) < 0) {
|
||||||
&net->info.addr.pci.bus,
|
|
||||||
&net->info.addr.pci.slot) < 0) {
|
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
goto try_remove;
|
goto try_remove;
|
||||||
}
|
}
|
||||||
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
||||||
|
memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -5300,6 +5300,7 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn,
|
|||||||
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
|
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
|
||||||
pciDevice *pci;
|
pciDevice *pci;
|
||||||
int ret;
|
int ret;
|
||||||
|
virDomainDevicePCIAddress guestAddr;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
|
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
|
||||||
virReportOOMError(conn);
|
virReportOOMError(conn);
|
||||||
@ -5327,17 +5328,13 @@ static int qemudDomainAttachHostPciDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
ret = qemuMonitorAddPCIHostDevice(priv->mon,
|
ret = qemuMonitorAddPCIHostDevice(priv->mon,
|
||||||
hostdev->source.subsys.u.pci.domain,
|
&hostdev->source.subsys.u.pci,
|
||||||
hostdev->source.subsys.u.pci.bus,
|
&guestAddr);
|
||||||
hostdev->source.subsys.u.pci.slot,
|
|
||||||
hostdev->source.subsys.u.pci.function,
|
|
||||||
&hostdev->info.addr.pci.domain,
|
|
||||||
&hostdev->info.addr.pci.bus,
|
|
||||||
&hostdev->info.addr.pci.slot);
|
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error;
|
goto error;
|
||||||
hostdev->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
hostdev->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
||||||
|
memcpy(&hostdev->info.addr.pci, &guestAddr, sizeof(guestAddr));
|
||||||
|
|
||||||
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
||||||
|
|
||||||
@ -5576,9 +5573,7 @@ static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
if (qemuMonitorRemovePCIDevice(priv->mon,
|
if (qemuMonitorRemovePCIDevice(priv->mon,
|
||||||
detach->info.addr.pci.domain,
|
&detach->info.addr.pci) < 0) {
|
||||||
detach->info.addr.pci.bus,
|
|
||||||
detach->info.addr.pci.slot) < 0) {
|
|
||||||
qemuDomainObjExitMonitor(vm);
|
qemuDomainObjExitMonitor(vm);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -5648,9 +5643,7 @@ qemudDomainDetachNetDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
if (qemuMonitorRemovePCIDevice(priv->mon,
|
if (qemuMonitorRemovePCIDevice(priv->mon,
|
||||||
detach->info.addr.pci.domain,
|
&detach->info.addr.pci) < 0) {
|
||||||
detach->info.addr.pci.bus,
|
|
||||||
detach->info.addr.pci.slot) < 0) {
|
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -5737,9 +5730,7 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
|
|||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
if (qemuMonitorRemovePCIDevice(priv->mon,
|
if (qemuMonitorRemovePCIDevice(priv->mon,
|
||||||
detach->info.addr.pci.domain,
|
&detach->info.addr.pci) < 0) {
|
||||||
detach->info.addr.pci.bus,
|
|
||||||
detach->info.addr.pci.slot) < 0) {
|
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1117,33 +1117,18 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
|
int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
|
||||||
unsigned hostDomain,
|
virDomainDevicePCIAddress *hostAddr,
|
||||||
unsigned hostBus,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned hostSlot,
|
|
||||||
unsigned hostFunction,
|
|
||||||
unsigned *guestDomain,
|
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d function=%d",
|
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d function=%d",
|
||||||
mon, mon->fd,
|
mon, mon->fd,
|
||||||
hostDomain, hostBus, hostSlot, hostFunction);
|
hostAddr->domain, hostAddr->bus, hostAddr->slot, hostAddr->function);
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
ret = qemuMonitorJSONAddPCIHostDevice(mon, hostDomain,
|
ret = qemuMonitorJSONAddPCIHostDevice(mon, hostAddr, guestAddr);
|
||||||
hostBus, hostSlot,
|
|
||||||
hostFunction,
|
|
||||||
guestDomain,
|
|
||||||
guestBus,
|
|
||||||
guestSlot);
|
|
||||||
else
|
else
|
||||||
ret = qemuMonitorTextAddPCIHostDevice(mon, hostDomain,
|
ret = qemuMonitorTextAddPCIHostDevice(mon, hostAddr, guestAddr);
|
||||||
hostBus, hostSlot,
|
|
||||||
hostFunction,
|
|
||||||
guestDomain,
|
|
||||||
guestBus,
|
|
||||||
guestSlot);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,58 +1136,47 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
|
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *bus,
|
const char *bus,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
DEBUG("mon=%p, fd=%d path=%s bus=%s",
|
DEBUG("mon=%p, fd=%d path=%s bus=%s",
|
||||||
mon, mon->fd, path, bus);
|
mon, mon->fd, path, bus);
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
ret = qemuMonitorJSONAddPCIDisk(mon, path, bus,
|
ret = qemuMonitorJSONAddPCIDisk(mon, path, bus, guestAddr);
|
||||||
guestDomain, guestBus, guestSlot);
|
|
||||||
else
|
else
|
||||||
ret = qemuMonitorTextAddPCIDisk(mon, path, bus,
|
ret = qemuMonitorTextAddPCIDisk(mon, path, bus, guestAddr);
|
||||||
guestDomain, guestBus, guestSlot);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
|
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
|
||||||
const char *nicstr,
|
const char *nicstr,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
DEBUG("mon=%p, fd=%d nicstr=%s", mon, mon->fd, nicstr);
|
DEBUG("mon=%p, fd=%d nicstr=%s", mon, mon->fd, nicstr);
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
ret = qemuMonitorJSONAddPCINetwork(mon, nicstr, guestDomain,
|
ret = qemuMonitorJSONAddPCINetwork(mon, nicstr, guestAddr);
|
||||||
guestBus, guestSlot);
|
|
||||||
else
|
else
|
||||||
ret = qemuMonitorTextAddPCINetwork(mon, nicstr, guestDomain,
|
ret = qemuMonitorTextAddPCINetwork(mon, nicstr, guestAddr);
|
||||||
guestBus, guestSlot);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
|
int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
|
||||||
unsigned guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned guestBus,
|
|
||||||
unsigned guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d",
|
DEBUG("mon=%p, fd=%d domain=%d bus=%d slot=%d function=%d",
|
||||||
mon, mon->fd, guestDomain, guestBus, guestSlot);
|
mon, mon->fd, guestAddr->domain, guestAddr->bus,
|
||||||
|
guestAddr->slot, guestAddr->function);
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
ret = qemuMonitorJSONRemovePCIDevice(mon, guestDomain,
|
ret = qemuMonitorJSONRemovePCIDevice(mon, guestAddr);
|
||||||
guestBus, guestSlot);
|
|
||||||
else
|
else
|
||||||
ret = qemuMonitorTextRemovePCIDevice(mon, guestDomain,
|
ret = qemuMonitorTextRemovePCIDevice(mon, guestAddr);
|
||||||
guestBus, guestSlot);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,13 +222,8 @@ int qemuMonitorAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
|
int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
|
||||||
unsigned hostDomain,
|
virDomainDevicePCIAddress *hostAddr,
|
||||||
unsigned hostBus,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned hostSlot,
|
|
||||||
unsigned hostFunction,
|
|
||||||
unsigned *guestDomain,
|
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
/* XXX disk driver type eg, qcow/etc.
|
/* XXX disk driver type eg, qcow/etc.
|
||||||
* XXX cache mode
|
* XXX cache mode
|
||||||
@ -236,23 +231,17 @@ int qemuMonitorAddPCIHostDevice(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
|
int qemuMonitorAddPCIDisk(qemuMonitorPtr mon,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *bus,
|
const char *bus,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
/* XXX do we really want to hardcode 'nicstr' as the
|
/* XXX do we really want to hardcode 'nicstr' as the
|
||||||
* sendable item here
|
* sendable item here
|
||||||
*/
|
*/
|
||||||
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
|
int qemuMonitorAddPCINetwork(qemuMonitorPtr mon,
|
||||||
const char *nicstr,
|
const char *nicstr,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
|
int qemuMonitorRemovePCIDevice(qemuMonitorPtr mon,
|
||||||
unsigned guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned guestBus,
|
|
||||||
unsigned guestSlot);
|
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
|
int qemuMonitorSendFileHandle(qemuMonitorPtr mon,
|
||||||
|
@ -1206,9 +1206,7 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|||||||
/* XXX qemu also returns a 'function' number now */
|
/* XXX qemu also returns a 'function' number now */
|
||||||
static int
|
static int
|
||||||
qemuMonitorJSONGetGuestAddress(virJSONValuePtr reply,
|
qemuMonitorJSONGetGuestAddress(virJSONValuePtr reply,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
virJSONValuePtr addr;
|
virJSONValuePtr addr;
|
||||||
|
|
||||||
@ -1219,47 +1217,48 @@ qemuMonitorJSONGetGuestAddress(virJSONValuePtr reply,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectGetNumberUint(addr, "domain", guestDomain) < 0) {
|
if (virJSONValueObjectGetNumberUint(addr, "domain", &guestAddr->domain) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("pci_add reply was missing device domain number"));
|
_("pci_add reply was missing device domain number"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectGetNumberUint(addr, "bus", guestBus) < 0) {
|
if (virJSONValueObjectGetNumberUint(addr, "bus", &guestAddr->bus) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("pci_add reply was missing device bus number"));
|
_("pci_add reply was missing device bus number"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectGetNumberUint(addr, "slot", guestSlot) < 0) {
|
if (virJSONValueObjectGetNumberUint(addr, "slot", &guestAddr->slot) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("pci_add reply was missing device slot number"));
|
_("pci_add reply was missing device slot number"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virJSONValueObjectGetNumberUint(addr, "function", &guestAddr->function) < 0) {
|
||||||
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("pci_add reply was missing device function number"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
||||||
unsigned hostDomain ATTRIBUTE_UNUSED,
|
virDomainDevicePCIAddress *hostAddr,
|
||||||
unsigned hostBus,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned hostSlot,
|
|
||||||
unsigned hostFunction,
|
|
||||||
unsigned *guestDomain,
|
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
char *dev;
|
char *dev;
|
||||||
|
|
||||||
*guestDomain = *guestBus = *guestSlot = 0;
|
memset(guestAddr, 0, sizeof(*guestAddr));
|
||||||
|
|
||||||
/* XXX hostDomain */
|
/* XXX hostDomain */
|
||||||
if (virAsprintf(&dev, "host=%.2x:%.2x.%.1x",
|
if (virAsprintf(&dev, "host=%.2x:%.2x.%.1x",
|
||||||
hostBus, hostSlot, hostFunction) < 0) {
|
hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1279,7 +1278,7 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
|||||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||||
|
|
||||||
if (ret == 0 &&
|
if (ret == 0 &&
|
||||||
qemuMonitorJSONGetGuestAddress(reply, guestDomain, guestBus, guestSlot) < 0)
|
qemuMonitorJSONGetGuestAddress(reply, guestAddr) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
@ -1291,15 +1290,14 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *bus,
|
const char *bus,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
{
|
||||||
unsigned *guestSlot) {
|
|
||||||
int ret;
|
int ret;
|
||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
char *dev;
|
char *dev;
|
||||||
|
|
||||||
*guestDomain = *guestBus = *guestSlot = 0;
|
memset(guestAddr, 0, sizeof(*guestAddr));
|
||||||
|
|
||||||
if (virAsprintf(&dev, "file=%s,if=%s", path, bus) < 0) {
|
if (virAsprintf(&dev, "file=%s,if=%s", path, bus) < 0) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
@ -1321,7 +1319,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
|||||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||||
|
|
||||||
if (ret == 0 &&
|
if (ret == 0 &&
|
||||||
qemuMonitorJSONGetGuestAddress(reply, guestDomain, guestBus, guestSlot) < 0)
|
qemuMonitorJSONGetGuestAddress(reply, guestAddr) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
@ -1332,9 +1330,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
||||||
const char *nicstr,
|
const char *nicstr,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("pci_add",
|
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("pci_add",
|
||||||
@ -1344,7 +1340,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
|||||||
NULL);
|
NULL);
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
|
|
||||||
*guestDomain = *guestBus = *guestSlot = 0;
|
memset(guestAddr, 0, sizeof(*guestAddr));
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1355,7 +1351,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
|||||||
ret = qemuMonitorJSONCheckError(cmd, reply);
|
ret = qemuMonitorJSONCheckError(cmd, reply);
|
||||||
|
|
||||||
if (ret == 0 &&
|
if (ret == 0 &&
|
||||||
qemuMonitorJSONGetGuestAddress(reply, guestDomain, guestBus, guestSlot) < 0)
|
qemuMonitorJSONGetGuestAddress(reply, guestAddr) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
@ -1365,17 +1361,16 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
|
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
|
||||||
unsigned guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned guestBus,
|
|
||||||
unsigned guestSlot)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
virJSONValuePtr cmd;
|
virJSONValuePtr cmd;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
char *addr;
|
char *addr;
|
||||||
|
|
||||||
|
/* XXX what about function ? */
|
||||||
if (virAsprintf(&addr, "%.4x:%.2x:%.2x",
|
if (virAsprintf(&addr, "%.4x:%.2x:%.2x",
|
||||||
guestDomain, guestBus, guestSlot) < 0) {
|
guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -112,32 +112,20 @@ int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
|
||||||
unsigned hostDomain,
|
virDomainDevicePCIAddress *hostAddr,
|
||||||
unsigned hostBus,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned hostSlot,
|
|
||||||
unsigned hostFunction,
|
|
||||||
unsigned *guestDomain,
|
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *bus,
|
const char *bus,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
|
||||||
const char *nicstr,
|
const char *nicstr,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
|
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
|
||||||
unsigned guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned guestBus,
|
|
||||||
unsigned guestSlot);
|
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
|
int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
|
||||||
const char *fdname,
|
const char *fdname,
|
||||||
|
@ -1281,9 +1281,7 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|||||||
static int
|
static int
|
||||||
qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||||
const char *reply,
|
const char *reply,
|
||||||
unsigned *domain,
|
virDomainDevicePCIAddress *addr)
|
||||||
unsigned *bus,
|
|
||||||
unsigned *slot)
|
|
||||||
{
|
{
|
||||||
char *s, *e;
|
char *s, *e;
|
||||||
|
|
||||||
@ -1300,7 +1298,7 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
|||||||
if (STRPREFIX(s, "domain ")) {
|
if (STRPREFIX(s, "domain ")) {
|
||||||
s += strlen("domain ");
|
s += strlen("domain ");
|
||||||
|
|
||||||
if (virStrToLong_ui(s, &e, 10, domain) == -1) {
|
if (virStrToLong_ui(s, &e, 10, &addr->domain) == -1) {
|
||||||
VIR_WARN(_("Unable to parse domain number '%s'\n"), s);
|
VIR_WARN(_("Unable to parse domain number '%s'\n"), s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1318,7 +1316,7 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
s += strlen("bus ");
|
s += strlen("bus ");
|
||||||
|
|
||||||
if (virStrToLong_ui(s, &e, 10, bus) == -1) {
|
if (virStrToLong_ui(s, &e, 10, &addr->bus) == -1) {
|
||||||
VIR_WARN(_("Unable to parse bus number '%s'\n"), s);
|
VIR_WARN(_("Unable to parse bus number '%s'\n"), s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1335,7 +1333,7 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
s += strlen("slot ");
|
s += strlen("slot ");
|
||||||
|
|
||||||
if (virStrToLong_ui(s, &e, 10, slot) == -1) {
|
if (virStrToLong_ui(s, &e, 10, &addr->slot) == -1) {
|
||||||
VIR_WARN(_("Unable to parse slot number '%s'\n"), s);
|
VIR_WARN(_("Unable to parse slot number '%s'\n"), s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1345,23 +1343,18 @@ qemuMonitorTextParsePciAddReply(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
|
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
|
||||||
unsigned hostDomain ATTRIBUTE_UNUSED,
|
virDomainDevicePCIAddress *hostAddr,
|
||||||
unsigned hostBus,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned hostSlot,
|
|
||||||
unsigned hostFunction,
|
|
||||||
unsigned *guestDomain,
|
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
char *reply = NULL;
|
char *reply = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
*guestDomain = *guestBus = *guestSlot = 0;
|
memset(guestAddr, 0, sizeof(*guestAddr));
|
||||||
|
|
||||||
/* XXX hostDomain */
|
/* XXX hostAddr->domain */
|
||||||
if (virAsprintf(&cmd, "pci_add pci_addr=auto host host=%.2x:%.2x.%.1x",
|
if (virAsprintf(&cmd, "pci_add pci_addr=auto host host=%.2x:%.2x.%.1x",
|
||||||
hostBus, hostSlot, hostFunction) < 0) {
|
hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1378,10 +1371,7 @@ int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorTextParsePciAddReply(mon, reply,
|
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
|
||||||
guestDomain,
|
|
||||||
guestBus,
|
|
||||||
guestSlot) < 0) {
|
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("parsing pci_add reply failed: %s"), reply);
|
_("parsing pci_add reply failed: %s"), reply);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1399,9 +1389,8 @@ cleanup:
|
|||||||
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
|
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *bus,
|
const char *bus,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
{
|
||||||
unsigned *guestSlot) {
|
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
char *reply = NULL;
|
char *reply = NULL;
|
||||||
char *safe_path = NULL;
|
char *safe_path = NULL;
|
||||||
@ -1427,8 +1416,7 @@ try_command:
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorTextParsePciAddReply(mon, reply,
|
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
|
||||||
guestDomain, guestBus, guestSlot) < 0) {
|
|
||||||
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
|
if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
|
||||||
VIR_FREE(reply);
|
VIR_FREE(reply);
|
||||||
VIR_FREE(cmd);
|
VIR_FREE(cmd);
|
||||||
@ -1453,9 +1441,7 @@ cleanup:
|
|||||||
|
|
||||||
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
|
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
|
||||||
const char *nicstr,
|
const char *nicstr,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot)
|
|
||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
char *reply = NULL;
|
char *reply = NULL;
|
||||||
@ -1472,8 +1458,7 @@ int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuMonitorTextParsePciAddReply(mon, reply,
|
if (qemuMonitorTextParsePciAddReply(mon, reply, guestAddr) < 0) {
|
||||||
guestDomain, guestBus, guestSlot) < 0) {
|
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("parsing pci_add reply failed: %s"), reply);
|
_("parsing pci_add reply failed: %s"), reply);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1489,9 +1474,7 @@ cleanup:
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
|
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
|
||||||
unsigned guestDomain,
|
virDomainDevicePCIAddress *guestAddr)
|
||||||
unsigned guestBus,
|
|
||||||
unsigned guestSlot)
|
|
||||||
{
|
{
|
||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
char *reply = NULL;
|
char *reply = NULL;
|
||||||
@ -1500,13 +1483,14 @@ int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
try_command:
|
try_command:
|
||||||
if (tryOldSyntax) {
|
if (tryOldSyntax) {
|
||||||
if (virAsprintf(&cmd, "pci_del 0 %.2x", guestSlot) < 0) {
|
if (virAsprintf(&cmd, "pci_del 0 %.2x", guestAddr->slot) < 0) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* XXX function ? */
|
||||||
if (virAsprintf(&cmd, "pci_del pci_addr=%.4x:%.2x:%.2x",
|
if (virAsprintf(&cmd, "pci_del pci_addr=%.4x:%.2x:%.2x",
|
||||||
guestDomain, guestBus, guestSlot) < 0) {
|
guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1534,7 +1518,7 @@ try_command:
|
|||||||
strstr(reply, "Invalid pci address")) {
|
strstr(reply, "Invalid pci address")) {
|
||||||
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"),
|
_("failed to detach PCI device, invalid address %.4x:%.2x:%.2x: %s"),
|
||||||
guestDomain, guestBus, guestSlot, reply);
|
guestAddr->domain, guestAddr->bus, guestAddr->slot, reply);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,32 +116,20 @@ int qemuMonitorTextAddUSBDeviceMatch(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
|
|
||||||
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
|
int qemuMonitorTextAddPCIHostDevice(qemuMonitorPtr mon,
|
||||||
unsigned hostDomain,
|
virDomainDevicePCIAddress *hostAddr,
|
||||||
unsigned hostBus,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned hostSlot,
|
|
||||||
unsigned hostFunction,
|
|
||||||
unsigned *guestDomain,
|
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
|
int qemuMonitorTextAddPCIDisk(qemuMonitorPtr mon,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *bus,
|
const char *bus,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
|
int qemuMonitorTextAddPCINetwork(qemuMonitorPtr mon,
|
||||||
const char *nicstr,
|
const char *nicstr,
|
||||||
unsigned *guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned *guestBus,
|
|
||||||
unsigned *guestSlot);
|
|
||||||
|
|
||||||
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
|
int qemuMonitorTextRemovePCIDevice(qemuMonitorPtr mon,
|
||||||
unsigned guestDomain,
|
virDomainDevicePCIAddress *guestAddr);
|
||||||
unsigned guestBus,
|
|
||||||
unsigned guestSlot);
|
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
|
int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
|
||||||
const char *fdname,
|
const char *fdname,
|
||||||
|
Loading…
Reference in New Issue
Block a user