Re: [PATCH v2.1 08/11] qemu_migration: Implement qemuMigrationStartNBDServer()

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

 



On Fri, Jan 11, 2013 at 17:52:20 +0100, Michal Privoznik wrote:
> We need to start NBD server and feed it with all non-<shared/> disks.
> However, after qemuDomainObjEnterMonitorAsync the domain object
> is unlocked so we cannot touch its disk definitions. Therefore,
> we must prepare the list of disk IDs prior entering monitor.
> ---
>  src/qemu/qemu_migration.c | 59 +++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 57 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index 367747c..fc410c0 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -35,6 +35,7 @@
>  #include "qemu_domain.h"
>  #include "qemu_process.h"
>  #include "qemu_capabilities.h"
> +#include "qemu_command.h"
>  #include "qemu_cgroup.h"
>  
>  #include "domain_audit.h"
> @@ -1116,8 +1117,62 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
>                              virDomainObjPtr vm ATTRIBUTE_UNUSED,
>                              int *nbdPort ATTRIBUTE_UNUSED)
>  {
> -    /* do nothing for now */
> -    return 0;
> +    int ret = -1;
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    int port = qemuMigrationNextPort();
> +    const char *listen = "0.0.0.0";

Does nbd-server-start support IPv6?

> +    char **disks = NULL;
> +    size_t i, ndisks = 0;
> +
> +    for (i = 0; i < vm->def->ndisks; i++) {
> +        virDomainDiskDefPtr disk = vm->def->disks[i];
> +
> +        /* skip shared disks */
> +        if (disk->shared)
> +            continue;
> +
> +        if (VIR_REALLOC_N(disks, ndisks + 1) < 0) {
> +            virReportOOMError();
> +            goto cleanup;
> +        }

Personally, I'd just preallocate the array for vm->def->ndisks elements
rather than doing several allocations in a loop.

> +
> +        if (virAsprintf(&disks[ndisks++], "%s%s",
> +                        QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) {
> +            virReportOOMError();
> +            goto cleanup;
> +        }
> +    }
> +
> +    if (!ndisks) {
> +        /* Hooray! Nothing to care about */
> +        ret = 0;
> +        goto cleanup;
> +    }
> +
> +    if (qemuDomainObjEnterMonitorAsync(driver, vm,
> +                                       QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
> +        goto cleanup;
> +
> +    if (qemuMonitorNBDServerStart(priv->mon, listen, port) < 0)
> +        goto endjob;
> +
> +    for (i = 0; i < ndisks; i++) {
> +        if (qemuMonitorNBDServerAdd(priv->mon, disks[i], true) < 0) {
> +            VIR_WARN("Unable to add '%s' to NDB server", disks[i]);
> +            goto endjob;
> +        }
> +    }
> +
> +    *nbdPort = port;
> +    ret = 0;
> +
> +endjob:
> +    qemuDomainObjExitMonitorWithDriver(driver, vm);
> +cleanup:
> +    for (i = 0; i < ndisks; i++)
> +        VIR_FREE(disks[i]);
> +    VIR_FREE(disks);
> +    return ret;
>  }

And definitely squash this patch into 6/11.

Jirka

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