tests: Move debug-drives testing API to launch.c and change the output.

It should work with any attach-method.
This commit is contained in:
Richard W.M. Jones
2012-07-23 18:56:20 +01:00
parent a6366f5dae
commit 3614d76b37
4 changed files with 38 additions and 28 deletions

View File

@@ -69,10 +69,10 @@ EOF
domain guest libvirturi:test://$cwd/test.xml readonly:true
debug-drives
EOF
grep -sq "test1.img.*snapshot=on" test.out
grep -sq "test1.img readonly" test.out
! grep -sq "test1.img.*format" test.out
grep -sq "test2.img.*snapshot=on.*format=raw" test.out
grep -sq "test3.img.*snapshot=on.*format=qcow2" test.out
grep -sq "test2.img readonly format=raw" test.out
grep -sq "test3.img readonly format=qcow2" test.out
# Test readonlydisk = "ignore".
./guestfish >test.out <<EOF

View File

@@ -67,10 +67,10 @@ EOF
./guestfish -c "test://$cwd/test.xml" --ro -d guest \
debug-drives </dev/null >test.out
grep -sq "test1.img.*snapshot=on" test.out
grep -sq "test1.img readonly" test.out
! grep -sq "test1.img.*format" test.out
grep -sq "test2.img.*snapshot=on.*format=raw" test.out
grep -sq "test3.img.*snapshot=on.*format=qcow2" test.out
grep -sq "test4.img.*snapshot=on.*format=raw" test.out
grep -sq "test2.img readonly format=raw" test.out
grep -sq "test3.img readonly format=qcow2" test.out
grep -sq "test4.img readonly format=raw" test.out
rm -f test1.img test2.img test3.img test4.img test.xml test.out

View File

@@ -1030,27 +1030,6 @@ guestfs__get_pid (guestfs_h *g)
}
}
/* Internal command to return the list of drives. */
char **
guestfs__debug_drives (guestfs_h *g)
{
size_t i, count;
char **ret;
struct drive *drv;
for (count = 0, drv = g->drives; drv; count++, drv = drv->next)
;
ret = safe_malloc (g, sizeof (char *) * (count + 1));
for (i = 0, drv = g->drives; drv; i++, drv = drv->next)
ret[i] = qemu_drive_param (g, drv, i);
ret[count] = NULL;
return ret; /* caller frees */
}
/* Maximum number of disks. */
int
guestfs__max_disks (guestfs_h *g)

View File

@@ -289,6 +289,37 @@ guestfs__config (guestfs_h *g,
return 0;
}
/* Internal command to return the list of drives. */
char **
guestfs__debug_drives (guestfs_h *g)
{
size_t i, count;
char **ret;
struct drive *drv;
for (count = 0, drv = g->drives; drv; count++, drv = drv->next)
;
ret = safe_malloc (g, sizeof (char *) * (count + 1));
for (i = 0, drv = g->drives; drv; i++, drv = drv->next) {
ret[i] = safe_asprintf (g, "path=%s%s%s%s%s%s%s%s%s",
drv->path,
drv->readonly ? " readonly" : "",
drv->format ? " format=" : "",
drv->format ? : "",
drv->iface ? " iface=" : "",
drv->iface ? : "",
drv->name ? " name=" : "",
drv->name ? : "",
drv->use_cache_none ? " cache=none" : "");
}
ret[count] = NULL;
return ret; /* caller frees */
}
int
guestfs__launch (guestfs_h *g)
{