Re: [libvirt] [PATCH] qemu: migrate: Don't require manual URI to specify a port

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

 



On 10/28/2009 10:09 AM, Chris Lalancette wrote:
> Cole Robinson wrote:
>> The xen driver will generate a migration port if only a hostname is passed
>> in the optional migrate URI, so let's do the same in qemu.
>>
>> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
>> ---
>>  src/qemu/qemu_driver.c |   29 +++++++++++++++++++++++------
>>  1 files changed, 23 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>> index fb952d8..3ef29a6 100644
>> --- a/src/qemu/qemu_driver.c
>> +++ b/src/qemu/qemu_driver.c
>> @@ -6304,15 +6304,32 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
>>  
>>          /* Get the port number. */
>>          p = strrchr (uri_in, ':');
>> -        p++; /* definitely has a ':' in it, see above */
>> -        this_port = virParseNumber (&p);
>> -        if (this_port == -1 || p-uri_in != strlen (uri_in)) {
>> -            qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG,
>> -                              "%s", _("URI did not have ':port' at the end"));
>> -            goto cleanup;
>> +        if (p == strchr(uri_in, ':')) {
>> +            /* Generate a port */
>> +            this_port = QEMUD_MIGRATION_FIRST_PORT + port++;
>> +            if (port == QEMUD_MIGRATION_NUM_PORTS)
>> +                port = 0;
>> +
>> +            /* Caller frees */
>> +            if (virAsprintf(uri_out, "%s:%d", uri_in, this_port) < 0) {
>> +                virReportOOMError (dconn);
>> +                goto cleanup;
>> +            }
>> +
>> +        } else {
>> +            p++; /* definitely has a ':' in it, see above */
>> +            this_port = virParseNumber (&p);
>> +            if (this_port == -1 || p-uri_in != strlen (uri_in)) {
>> +                qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG,
>> +                                  "%s", _("URI ended with incorrect ':port'"));
>> +                goto cleanup;
>> +            }
>>          }
>>      }
>>  
>> +    if (uri_out && *uri_out)
>> +        VIR_DEBUG("Generated uri_out=%s", *uri_out);
>> +
>>      /* Parse the domain XML. */
>>      if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml,
>>                                          VIR_DOMAIN_XML_INACTIVE))) {
> 
> Yeah, good idea.  I also like the additional VIR_DEBUG print, that's useful.
> 
> ACK
> 

Thanks, pushed.

- Cole

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