Re: [RFC PATCH 7/8] qemu: Prepare basic APIs to handle invalid defs

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

 



On 13.10.2015 15:08, Martin Kletzander wrote:
> On Tue, Oct 13, 2015 at 12:10:05PM +0200, Michal Privoznik wrote:
>> On 22.09.2015 14:15, Martin Kletzander wrote:
>>> In order for the user to be able to fix broken domains function
>>> qemuDomainGetXMLDesc() needs to be able to lookup invalid domain
>>> definitions and handle them properly.  When redefined, function
>>> qemuDomainDefineXMLFlags() must clear the 'invalid XML' reason.  As a
>>> nice addition, qemuDomainGetState() can lookup such domains without any
>>> other change and that allows virsh not only to get their status, but
>>> also to list them.
>>>
>>> Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
>>> ---
>>>  src/qemu/qemu_driver.c | 21 ++++++++++++++-------
>>>  1 file changed, 14 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>>> index 0a671500134f..881c5c4c1984 100644
>>> --- a/src/qemu/qemu_driver.c
>>> +++ b/src/qemu/qemu_driver.c
>>> @@ -2706,7 +2706,7 @@ qemuDomainGetState(virDomainPtr dom,
>>>
>>>      virCheckFlags(0, -1);
>>>
>>> -    if (!(vm = qemuDomObjFromDomain(dom)))
>>> +    if (!(vm = qemuDomObjFromDomainInvalid(dom)))
>>>          goto cleanup;
>>>
>>>      if (virDomainGetStateEnsureACL(dom->conn, vm->def) < 0)
>>> @@ -7082,19 +7082,23 @@ qemuDomainGetXMLDesc(virDomainPtr dom,
>>>
>>>      /* Flags checked by virDomainDefFormat */
>>>
>>> -    if (!(vm = qemuDomObjFromDomain(dom)))
>>> +    if (!(vm = qemuDomObjFromDomainInvalid(dom)))
>>>          goto cleanup;
>>>
>>>      if (virDomainGetXMLDescEnsureACL(dom->conn, vm->def, flags) < 0)
>>>          goto cleanup;
>>>
>>> -    if (qemuDomainUpdateCurrentMemorySize(driver, vm) < 0)
>>> -        goto cleanup;
>>> +    if (vm->def->parseError) {
>>> +        ignore_value(VIR_STRDUP(ret, vm->def->xmlStr));
>>> +    } else {
>>> +        if (qemuDomainUpdateCurrentMemorySize(driver, vm) < 0)
>>> +            goto cleanup;
>>>
>>> -    if ((flags & VIR_DOMAIN_XML_MIGRATABLE))
>>> -        flags |= QEMU_DOMAIN_FORMAT_LIVE_FLAGS;
>>> +        if ((flags & VIR_DOMAIN_XML_MIGRATABLE))
>>> +            flags |= QEMU_DOMAIN_FORMAT_LIVE_FLAGS;
>>>
>>> -    ret = qemuDomainFormatXML(driver, vm, flags);
>>> +        ret = qemuDomainFormatXML(driver, vm, flags);
>>> +    }
>>>
>>>   cleanup:
>>>      virDomainObjEndAPI(&vm);
>>> @@ -7557,6 +7561,9 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
>>>          goto cleanup;
>>>      }
>>>
>>> +    if (oldDef && oldDef->parseError)
>>> +        virDomainObjSetState(vm, virDomainObjGetState(vm, NULL), 0);
>>> +
>>
>> I don't understand this bit. Why is this needed?
>>
> 
> This resets the domain state reason to "unknown" (while keeping the
> state) which is the same one as the properly-loaded domains have.
> Otherwise it would keep the INVALID_XML reason -- virshdomstate
> --reason would output shutoff (invalid xml).

Ah, okay. ACK then.

Michal

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