Re: [PATCH 14/15] tests: add qcow2 data-file tests

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

 



On Wed, Nov 20, 2024 at 18:48:49 +0300, Nikolai Barybin via Devel wrote:
> - qemuxmlconftest: check various xml definitions of dataFileStore:
> types file, block, network and the case when data-file belongs
> to qcow2 backing image
> 
> - virstoragetest: create qcow2 image chains and check that data files
> are properly probed by metadata parser
> 
> - qemuxmlactivetest: check that status files will contain data files'
> node names

Each of the above should have been a separate patch. I'll thus split up
this into 3 patches, each for it's own test program.

> 
> Signed-off-by: Nikolai Barybin <nikolai.barybin@xxxxxxxxxxxxx>
> ---

[...]

> +static void
> +testPrepImagesWithQcow2DataFiles(char **chains)
> +{
> +    g_autoptr(virCommand) cmdData1 = NULL;
> +    g_autoptr(virCommand) cmdData2 = NULL;
> +    g_autoptr(virCommand) cmdqcow2_1 = NULL;
> +    g_autoptr(virCommand) cmdqcow2_2_backing = NULL;
> +    g_autoptr(virCommand) cmdqcow2_2 = NULL;
> +    g_autofree char *data1 = g_strdup_printf("%s/data-1", datadir);
> +    g_autofree char *data2 = g_strdup_printf("%s/data-2", datadir);
> +    g_autofree char *qcow2_1 = g_strdup_printf("%s/qcow2-1", datadir);
> +    g_autofree char *qcow2_1_opt_create = g_strdup_printf("data_file=%s,data_file_raw=true", data1);
> +    g_autofree char *qcow2_2_backing = g_strdup_printf("%s/qcow2-2-backing", datadir);
> +    g_autofree char *qcow2_2_backing_opt_create = g_strdup_printf("data_file=%s,data_file_raw=true", data2);
> +    g_autofree char *qcow2_2 = g_strdup_printf("%s/qcow2-2", datadir);
> +    g_autofree char *qemuimg = virFindFileInPath("qemu-img");
> +
> +    if (!qemuimg)
> +        return;
> +
> +    /* Clean up from any earlier failed tests */
> +    virFileDeleteTree(datadir);
> +
> +    if (g_mkdir_with_parents(datadir, 0777) < 0) {
> +        VIR_TEST_VERBOSE("unable to create directory '%s'\n", datadir);
> +        return;
> +    }
> +
> +    /* create 2 chains containing data-file
> +     * 1. qcow2 image with data-file
> +     * 2. qcow2 image with backing qcow2 image containing data-file */
> +    cmdData1 = virCommandNewArgList(qemuimg, "create",
> +                                    "-f", "raw",
> +                                    data1, "1k",  NULL);
> +    cmdData2 = virCommandNewArgList(qemuimg, "create",
> +                                    "-f", "raw",
> +                                    data2, "1k",  NULL);
> +
> +    cmdqcow2_1 = virCommandNewArgList(qemuimg, "create",
> +                                      "-f", "qcow2",
> +                                      "-o", qcow2_1_opt_create,
> +                                      qcow2_1, "1k", NULL);
> +
> +    cmdqcow2_2_backing = virCommandNewArgList(qemuimg, "create",
> +                                              "-f", "qcow2",
> +                                              "-o", qcow2_2_backing_opt_create,
> +                                              qcow2_2_backing, "1k", NULL);
> +
> +    cmdqcow2_2 = virCommandNewArgList(qemuimg, "create",
> +                                      "-f", "qcow2",
> +                                      "-F", "qcow2",
> +                                      "-b", qcow2_2_backing,
> +                                      qcow2_2, NULL);
> +
> +    if (virCommandRun(cmdData1, NULL) < 0 ||
> +        virCommandRun(cmdData2, NULL) < 0 ||
> +        virCommandRun(cmdqcow2_1, NULL) < 0 ||
> +        virCommandRun(cmdqcow2_2_backing, NULL) < 0 ||
> +        virCommandRun(cmdqcow2_2, NULL) < 0) {
> +        VIR_TEST_VERBOSE("failed to create backing chain with data file in '%s'\n", datadir);
> +        return;

While all of the above will be deleted ... this error handling doesn't
make sense, as you don't actually signal a failure to the caller,
letting it fail later.

> +    }
> +
> +    chains[0] = g_steal_pointer(&qcow2_1);
> +    chains[1] = g_steal_pointer(&qcow2_2);
> +
> +    return;
> +}

Historically I've refactored virstoragetest to avoid use of 'qemu-img'
so I'll delete all of the above and replace it with example images
directly commited into the repository as we do with most of the other
cases.



[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]

  Powered by Linux