[PATCH 2/6] block_resize: Implemente the public API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/libvirt.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index e4a21b6..a9b4b3c 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -6620,6 +6620,73 @@ error:
 }
 
 /**
+ * virDomainBlockResize:
+ * @dom: pointer to the domain object
+ * @devname: name of the block device
+ * @size: new size of the block image in kilobytes
+ * @flags: unused, always pass 0
+ *
+ * Note that this call may fail if the underlying virtualization hypervisor
+ * does not support it. And this call requires privileged access to the
+ * hypervisor.
+ *
+ * @devname is the name of the block device.  Get this by calling
+ * virDomainGetXMLDesc and finding the <target dev='...'>
+ * attribute within //domain/devices/disk.  (For example, "xvda").
+ *
+ * Resize a block device of domain while the domain is running.
+ *
+ * Returns: 0 in case of success or -1 in case of failure.
+ */
+
+int
+virDomainBlockResize (virDomainPtr dom,
+                      const char *devname,
+                      unsigned long long size,
+                      unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(dom, "devname=%s, size=%llu, flags=%x",
+                     devname, size, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+    conn = dom->conn;
+
+    if (dom->conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (!devname) {
+        virLibDomainError(VIR_ERR_INVALID_ARG,
+                           _("devname is NULL"));
+        goto error;
+    }
+
+    if (conn->driver->domainBlockResize) {
+        int ret;
+        ret =conn->driver->domainBlockResize(dom, devname, size, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(dom->conn);
+    return -1;
+}
+
+
+/**
  * virDomainMemoryPeek:
  * @dom: pointer to the domain object
  * @start: start of memory to peek
-- 
1.7.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]