]> xenbits.xensource.com Git - libvirt.git/commitdiff
test_driver: implement virDomainGetBlockInfo
authorIlias Stamatis <stamatis.iliass@gmail.com>
Thu, 8 Aug 2019 10:30:24 +0000 (12:30 +0200)
committerErik Skultety <eskultet@redhat.com>
Fri, 9 Aug 2019 08:23:52 +0000 (10:23 +0200)
Signed-off-by: Ilias Stamatis <stamatis.iliass@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/test/test_driver.c

index 6f18baa265a5a788f62577c83c2e3a491900ac5f..106e8f027e6082c58ffc29eb5df2e1f97e43baff 100755 (executable)
@@ -7729,6 +7729,45 @@ testDomainMemoryPeek(virDomainPtr dom,
 }
 
 
+static int
+testDomainGetBlockInfo(virDomainPtr dom,
+                       const char *path,
+                       virDomainBlockInfoPtr info,
+                       unsigned int flags)
+{
+    virDomainObjPtr vm = NULL;
+    virDomainDiskDefPtr disk;
+    int ret = -1;
+
+    virCheckFlags(0, -1);
+
+    if (!(vm = testDomObjFromDomain(dom)))
+        return -1;
+
+    if (!(disk = virDomainDiskByName(vm->def, path, false))) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("invalid path %s not assigned to domain"), path);
+        goto cleanup;
+    }
+
+    if (virStorageSourceIsEmpty(disk->src)) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("disk '%s' does not currently have a source assigned"),
+                       path);
+        goto cleanup;
+    }
+
+    info->capacity = 1099506450432;
+    info->allocation = 1099511627776;
+    info->physical = 1099511627776;
+
+    ret = 0;
+ cleanup:
+    virDomainObjEndAPI(&vm);
+    return ret;
+}
+
+
 /*
  * Snapshot APIs
  */
@@ -9031,6 +9070,7 @@ static virHypervisorDriver testHypervisorDriver = {
     .domainManagedSaveRemove = testDomainManagedSaveRemove, /* 1.1.4 */
     .domainMemoryStats = testDomainMemoryStats, /* 5.7.0 */
     .domainMemoryPeek = testDomainMemoryPeek, /* 5.4.0 */
+    .domainGetBlockInfo = testDomainGetBlockInfo, /* 5.7.0 */
 
     .domainSnapshotNum = testDomainSnapshotNum, /* 1.1.4 */
     .domainSnapshotListNames = testDomainSnapshotListNames, /* 1.1.4 */