qemu: fix nbdkit command test for backing chains

Previously this test only tested the generated nbdkit command for the
top level disk source. Update it to test the generated commmands for all
sources in the chain.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jonathon Jongsma 2024-01-26 10:41:58 -06:00
parent a883602c9a
commit bdece5518d
30 changed files with 76 additions and 60 deletions

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=ftp \ protocols=ftp \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-1/nbdkit-test-disk-1.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk1-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=ftps \ protocols=ftps \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-2/nbdkit-test-disk-2.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk2-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=https \ protocols=https \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground curl \ --foreground curl \
protocols=http,https \ protocols=http,https \
url=http://example.org:80/test.img \ url=http://example.org:80/test.img \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-1/nbdkit-test-disk-1.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk1-src0.socket \
--foreground curl \ --foreground curl \
protocols=https \ protocols=https \
url=https://example.org:443/test2.img url=https://example.org:443/test2.img

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-2/nbdkit-test-disk-2.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk2-src0.socket \
--foreground curl \ --foreground curl \
protocols=http,https \ protocols=http,https \
url=http://example.org:1234/test3.img \ url=http://example.org:1234/test3.img \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-3/nbdkit-test-disk-3.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk3-src0.socket \
--foreground curl \ --foreground curl \
protocols=https \ protocols=https \
'url=https://example.org:1234/test4.img?par=val&other=ble' \ 'url=https://example.org:1234/test4.img?par=val&other=ble' \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=https \ protocols=https \

View File

@ -0,0 +1,7 @@
nbdkit \
--unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src1.socket \
--foreground \
--readonly curl \
protocols=https \
url=https://https.example2.org:8444/path/to/backing.qcow2 \
cookie=-779

View File

@ -0,0 +1 @@
cookie3=cookievalue3; cookie4=cookievalue4

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=https \ protocols=https \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-1/nbdkit-test-disk-1.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk1-src0.socket \
--foreground curl \ --foreground curl \
protocols=https \ protocols=https \
'url=https://https.example.org:8443/path/to/disk5.iso?foo=bar' \ 'url=https://https.example.org:8443/path/to/disk5.iso?foo=bar' \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-2/nbdkit-test-disk-2.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk2-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=http,https \ protocols=http,https \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-3/nbdkit-test-disk-3.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk3-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=ftp \ protocols=ftp \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-4/nbdkit-test-disk-4.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk4-src0.socket \
--foreground \ --foreground \
--readonly curl \ --readonly curl \
protocols=ftps \ protocols=ftps \

View File

@ -1,6 +1,6 @@
SSH_AUTH_SOCK=/path/to/agent/socket \ SSH_AUTH_SOCK=/path/to/agent/socket \
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground ssh \ --foreground ssh \
host=example.org \ host=example.org \
port=2222 \ port=2222 \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-1/nbdkit-test-disk-1.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk1-src0.socket \
--foreground ssh \ --foreground ssh \
host=example.org \ host=example.org \
port=2222 \ port=2222 \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground ssh \ --foreground ssh \
host=example.org \ host=example.org \
port=2222 \ port=2222 \

View File

@ -1,5 +1,5 @@
nbdkit \ nbdkit \
--unix /tmp/statedir-0/nbdkit-test-disk-0.socket \ --unix /tmp/domain-QEMUGuest1/nbdkit-disk0-src0.socket \
--foreground ssh \ --foreground ssh \
host=example.org \ host=example.org \
port=2222 \ port=2222 \

View File

@ -174,7 +174,10 @@ testNbdkit(const void *data)
const TestInfo *info = data; const TestInfo *info = data;
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
size_t i; size_t i;
size_t n;
int ret = 0; int ret = 0;
virStorageSource *backing = NULL;
g_autofree char *statedir = NULL;
/* restart mock pipe fds so tests are consistent */ /* restart mock pipe fds so tests are consistent */
mockpipefd = PIPE_FD_START; mockpipefd = PIPE_FD_START;
@ -189,17 +192,18 @@ testNbdkit(const void *data)
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)))
return -1; return -1;
statedir = g_strdup_printf("/tmp/domain-%s", def->name);
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
virDomainDiskDef *disk = def->disks[i]; virDomainDiskDef *disk = def->disks[i];
g_autofree char *statedir = g_strdup_printf("/tmp/statedir-%zi", i); for (n = 0, backing = disk->src; backing != NULL; n++, backing = backing->backingStore) {
g_autofree char *alias = g_strdup_printf("test-disk-%zi", i); g_autofree char *alias = g_strdup_printf("disk%zi-src%zi", i, n);
g_autofree char *cmdfile = g_strdup_printf("%s.args.disk%zi", g_autofree char *cmdfile = g_strdup_printf("%s.args.%s",
info->outtemplate, i); info->outtemplate, alias);
if (qemuNbdkitInitStorageSource(info->nbdkitcaps, disk->src, statedir, if (qemuNbdkitInitStorageSource(info->nbdkitcaps, backing, statedir,
alias, 101, 101)) { alias, 101, 101)) {
qemuDomainStorageSourcePrivate *srcPriv = qemuDomainStorageSourcePrivate *srcPriv =
qemuDomainStorageSourcePrivateFetch(disk->src); qemuDomainStorageSourcePrivateFetch(backing);
g_autoptr(virCommand) cmd = NULL; g_autoptr(virCommand) cmd = NULL;
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew(); g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@ -208,6 +212,9 @@ testNbdkit(const void *data)
int nsendbuffers; int nsendbuffers;
size_t j; size_t j;
if (srcPriv->nbdkitProcess == NULL)
continue;
virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
cmd = qemuNbdkitProcessBuildCommand(srcPriv->nbdkitProcess); cmd = qemuNbdkitProcessBuildCommand(srcPriv->nbdkitProcess);
@ -242,6 +249,7 @@ testNbdkit(const void *data)
} }
} }
} }
}
if (info->expectFail) { if (info->expectFail) {
if (ret == 0) { if (ret == 0) {