}
-/**
- * qemuMonitorDriveDel:
- * @mon: monitor object
- * @drivestr: identifier of drive to delete.
- *
- * Attempts to remove a host drive.
- * Returns 1 if unsupported, 0 if ok, and -1 on other failure */
-int
-qemuMonitorDriveDel(qemuMonitor *mon,
- const char *drivestr)
-{
- VIR_DEBUG("drivestr=%s", drivestr);
-
- QEMU_CHECK_MONITOR(mon);
-
- /* there won't be a direct replacement for drive_del in QMP */
- return qemuMonitorTextDriveDel(mon, drivestr);
-}
-
-
/**
* @mon: monitor object
* @devalias: alias of the device to detach
}
-int
-qemuMonitorAddDrive(qemuMonitor *mon,
- const char *drivestr)
-{
- VIR_DEBUG("drive=%s", drivestr);
-
- QEMU_CHECK_MONITOR(mon);
-
- /* there won't ever be a direct QMP replacement for this function */
- return qemuMonitorTextAddDrive(mon, drivestr);
-}
-
-
int
qemuMonitorCreateSnapshot(qemuMonitor *mon, const char *name)
{
VIR_LOG_INIT("qemu.qemu_monitor_text");
-int qemuMonitorTextAddDrive(qemuMonitor *mon,
- const char *drivestr)
-{
- g_autofree char *cmd = NULL;
- g_autofree char *reply = NULL;
-
- /* 'dummy' here is just a placeholder since there is no PCI
- * address required when attaching drives to a controller */
- cmd = g_strdup_printf("drive_add dummy %s", drivestr);
-
- if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply) < 0)
- return -1;
-
- if (strstr(reply, "unknown command:")) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("drive hotplug is not supported"));
- return -1;
- }
-
- if (strstr(reply, "could not open disk image")) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("open disk image file failed"));
- return -1;
- }
-
- if (strstr(reply, "Could not open")) {
- size_t len = strlen(reply);
- if (reply[len - 1] == '\n')
- reply[len - 1] = '\0';
-
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- reply);
- return -1;
- }
-
- if (strstr(reply, "Image is not in")) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("Incorrect disk format"));
- return -1;
- }
-
- if (strstr(reply, "IOMMU") ||
- strstr(reply, "VFIO")) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- reply);
- return -1;
- }
-
- return 0;
-}
-
-
-int qemuMonitorTextDriveDel(qemuMonitor *mon,
- const char *drivestr)
-{
- g_autofree char *cmd = NULL;
- g_autofree char *reply = NULL;
-
- cmd = g_strdup_printf("drive_del %s", drivestr);
-
- if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply) < 0)
- return -1;
-
- if (strstr(reply, "unknown command:")) {
- VIR_ERROR(_("deleting drive is not supported. "
- "This may leak data if disk is reassigned"));
- return 1;
-
- /* (qemu) drive_del wark
- * Device 'wark' not found */
- } else if (strstr(reply, "Device '") && strstr(reply, "not found")) {
- /* NB: device not found errors mean the drive was auto-deleted and we
- * ignore the error */
- } else if (STRNEQ(reply, "")) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("deleting %s drive failed: %s"), drivestr, reply);
- return -1;
- }
-
- return 0;
-}
-
int
qemuMonitorTextCreateSnapshot(qemuMonitor *mon,
const char *name)