提交 efd4ee78 编写于 作者: D Daniel P. Berrange

Remove code from JSON monitor for commands that won't be ported

The QEMU developers have stated that they will not be porting
the commands 'pci_add', 'pci_del', 'usb_add', 'usb_del' to the
JSON mode monitor, since they're obsoleted by 'device_add'
and 'device_del'. libvirt has (untested) code that would have
supported those commands in theory, but since we already use
device_add/del where available, there's no need to keep the
legacy stuff anymore.

The text mode monitor keeps support for all commands for sake
of historical compatability.

* src/qemu/qemu_monitor_json.c: Remove 'pci_add', 'pci_del',
  'usb_add', 'usb_del' commands
上级 f6770e86
...@@ -1591,272 +1591,72 @@ int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon) ...@@ -1591,272 +1591,72 @@ int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon)
} }
static int qemuMonitorJSONAddUSB(qemuMonitorPtr mon, int qemuMonitorJSONAddUSBDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
const char *dev) const char *path ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("usb_add", _("usb_add not suppported in JSON mode"));
"s:devname", dev, return -1;
NULL);
virJSONValuePtr reply = NULL;
if (!cmd)
return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
int qemuMonitorJSONAddUSBDisk(qemuMonitorPtr mon,
const char *path)
{
int ret;
char *disk;
if (virAsprintf(&disk, "disk:%s", path) < 0) {
virReportOOMError();
return -1;
}
ret = qemuMonitorJSONAddUSB(mon, disk);
VIR_FREE(disk);
return ret;
}
int qemuMonitorJSONAddUSBDeviceExact(qemuMonitorPtr mon,
int bus,
int dev)
{
int ret;
char *addr;
if (virAsprintf(&addr, "host:%.3d.%.3d", bus, dev) < 0) {
virReportOOMError();
return -1;
}
ret = qemuMonitorJSONAddUSB(mon, addr);
VIR_FREE(addr);
return ret;
} }
int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon, int qemuMonitorJSONAddUSBDeviceExact(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
int vendor, int bus ATTRIBUTE_UNUSED,
int product) int dev ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
char *addr; _("usb_add not suppported in JSON mode"));
return -1;
if (virAsprintf(&addr, "host:%.4x:%.4x", vendor, product) < 0) {
virReportOOMError();
return -1;
}
ret = qemuMonitorJSONAddUSB(mon, addr);
VIR_FREE(addr);
return ret;
} }
static int int qemuMonitorJSONAddUSBDeviceMatch(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
qemuMonitorJSONGetGuestPCIAddress(virJSONValuePtr reply, int vendor ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *guestAddr) int product ATTRIBUTE_UNUSED)
{ {
virJSONValuePtr addr; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("usb_add not suppported in JSON mode"));
addr = virJSONValueObjectGet(reply, "return"); return -1;
if (!addr || addr->type != VIR_JSON_TYPE_OBJECT) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device address"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "domain", &guestAddr->domain) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device domain number"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "bus", &guestAddr->bus) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device bus number"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "slot", &guestAddr->slot) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device slot number"));
return -1;
}
if (virJSONValueObjectGetNumberUint(addr, "function", &guestAddr->function) < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pci_add reply was missing device function number"));
return -1;
}
return 0;
} }
int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon, int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *hostAddr, virDomainDevicePCIAddress *hostAddr ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *guestAddr) virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virJSONValuePtr cmd; _("pci_add not suppported in JSON mode"));
virJSONValuePtr reply = NULL; return -1;
char *dev;
memset(guestAddr, 0, sizeof(*guestAddr));
/* XXX hostDomain */
if (virAsprintf(&dev, "host=%.2x:%.2x.%.1x",
hostAddr->bus, hostAddr->slot, hostAddr->function) < 0) {
virReportOOMError();
return -1;
}
cmd = qemuMonitorJSONMakeCommand("pci_add",
"s:pci_addr", "auto"
"s:type", "host",
"s:opts", dev,
NULL);
VIR_FREE(dev);
if (!cmd)
return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestPCIAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
} }
int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon, int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
const char *path, const char *path ATTRIBUTE_UNUSED,
const char *bus, const char *bus ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *guestAddr) virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virJSONValuePtr cmd; _("pci_add not suppported in JSON mode"));
virJSONValuePtr reply = NULL; return -1;
char *dev;
memset(guestAddr, 0, sizeof(*guestAddr));
if (virAsprintf(&dev, "file=%s,if=%s", path, bus) < 0) {
virReportOOMError();
return -1;
}
cmd = qemuMonitorJSONMakeCommand("pci_add",
"s:pci_addr", "auto",
"s:type", "storage",
"s:opts", dev,
NULL);
VIR_FREE(dev);
if (!cmd)
return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestPCIAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
} }
int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon, int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
const char *nicstr, const char *nicstr ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *guestAddr) virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("pci_add", _("pci_add not suppported in JSON mode"));
"s:pci_addr", "auto", return -1;
"s:type", "nic",
"s:opts", nicstr,
NULL);
virJSONValuePtr reply = NULL;
memset(guestAddr, 0, sizeof(*guestAddr));
if (!cmd)
return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestPCIAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
} }
int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon, int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *guestAddr) virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virJSONValuePtr cmd; _("pci_del not suppported in JSON mode"));
virJSONValuePtr reply = NULL; return -1;
char *addr;
/* XXX what about function ? */
if (virAsprintf(&addr, "%.4x:%.2x:%.2x",
guestAddr->domain, guestAddr->bus, guestAddr->slot) < 0) {
virReportOOMError();
return -1;
}
cmd = qemuMonitorJSONMakeCommand("pci_del",
"s:pci_addr", addr,
NULL);
VIR_FREE(addr);
if (!cmd)
return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
} }
...@@ -2050,43 +1850,13 @@ int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon, ...@@ -2050,43 +1850,13 @@ int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon,
} }
int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon, int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
const char *bus, const char *bus ATTRIBUTE_UNUSED,
virDomainDevicePCIAddress *guestAddr) virDomainDevicePCIAddress *guestAddr ATTRIBUTE_UNUSED)
{ {
int ret; qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virJSONValuePtr cmd; _("pci_add not suppported in JSON mode"));
virJSONValuePtr reply = NULL; return -1;
char *dev;
memset(guestAddr, 0, sizeof(*guestAddr));
if (virAsprintf(&dev, "if=%s", bus) < 0) {
virReportOOMError();
return -1;
}
cmd = qemuMonitorJSONMakeCommand("pci_add",
"s:pci_addr", "auto",
"s:type", "storage",
"s:opts", dev,
NULL);
VIR_FREE(dev);
if (!cmd)
return -1;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
if (ret == 0 &&
qemuMonitorJSONGetGuestPCIAddress(reply, guestAddr) < 0)
ret = -1;
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册