]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Introduce nbd-server-add command
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Nov 2012 15:17:13 +0000 (16:17 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Sat, 23 Feb 2013 07:06:37 +0000 (08:06 +0100)
This will be used with new migration scheme.
This patch creates basically just monitor stub
functions. Wiring them into something useful
is done in later patches.

src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index 6160ad97777b221fa1d13cab2009d0a4119e45dd..239dcaedf96d33fd115231655f26361191bb2fa0 100644 (file)
@@ -3485,3 +3485,25 @@ int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
 
     return qemuMonitorJSONNBDServerStart(mon, host, port);
 }
+
+int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
+                            const char *deviceID,
+                            bool writable)
+{
+    VIR_DEBUG("mon=%p deviceID=%s",
+              mon, deviceID);
+
+    if (!mon) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("monitor must not be NULL"));
+        return -1;
+    }
+
+    if (!mon->json) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("JSON monitor is required"));
+        return -1;
+    }
+
+    return qemuMonitorJSONNBDServerAdd(mon, deviceID, writable);
+}
index 26d4d947ccbaa32275f0a39407574e0c6e178366..27c0587caa23497a9187bee4f61ac15b1ba59597 100644 (file)
@@ -679,6 +679,9 @@ char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
 int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
                               const char *host,
                               unsigned int port);
+int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
+                            const char *deviceID,
+                            bool writable);
 /**
  * When running two dd process and using <> redirection, we need a
  * shell that will not truncate files.  These two strings serve that
index c91d22609ca71323b83f3b4fa12d15fde6ae25a2..664084370b1d8002b9c2f9eb3f491582688c3c41 100644 (file)
@@ -4663,3 +4663,28 @@ cleanup:
     virJSONValueFree(data);
     return ret;
 }
+
+int
+qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
+                            const char *deviceID,
+                            bool writable)
+{
+    int ret = -1;
+    virJSONValuePtr cmd;
+    virJSONValuePtr reply = NULL;
+
+    if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-add",
+                                           "s:device", deviceID,
+                                           "b:writable", writable,
+                                           NULL)))
+        return ret;
+
+    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+    if (ret == 0)
+        ret = qemuMonitorJSONCheckError(cmd, reply);
+
+    virJSONValueFree(cmd);
+    virJSONValueFree(reply);
+    return ret;
+}
index 5d6372638b5366be50fb416cd0a8f7c3edb5b526..366eced1e744cd721f96be8dccc697a3c0b6a021 100644 (file)
@@ -337,4 +337,7 @@ char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
 int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
                                   const char *host,
                                   unsigned int port);
+int qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
+                                const char *deviceID,
+                                bool writable);
 #endif /* QEMU_MONITOR_JSON_H */