[PATCH] (#2) Fix a few bugs in the reset() call in CS

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1216845120 25200 # Node ID 9669e9cfbf6f7645c503a8f337cafe6a70028093 # Parent 427e74d2c45881820ee33b8b6cdeb9cff57a68c0 (#2) Fix a few bugs in the reset() call in CS. This fixes the following issues: -After the destroy call, the domain pointer is no longer valid. We need to get a new one to use for the Create call. -In the situation where the guest was created without being defined, we need to get the XML and then define the before calling the create call. Updates: -Remove unused virDomainInfo variable. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 427e74d2c458 -r 9669e9cfbf6f src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Mon Jul 21 13:28:13 2008 -0700 +++ b/src/Virt_ComputerSystem.c Wed Jul 23 13:32:00 2008 -0700 @@ -673,12 +673,44 @@ static int domain_reset(virDomainPtr dom) { int ret; + virConnectPtr conn = NULL; + char *xml = NULL; + + conn = virDomainGetConnect(dom); + if (conn == NULL) { + CU_DEBUG("Unable to get connection from domain"); + return 1; + } + + xml = virDomainGetXMLDesc(dom, 0); + if (xml == NULL) { + CU_DEBUG("Unable to retrieve domain XML"); + return 1; + } ret = virDomainDestroy(dom); if (ret) - return ret; + goto out; + + dom = virDomainLookupByName(virDomainGetConnect(dom), + virDomainGetName(dom)); + + if (dom == NULL) { + dom = virDomainDefineXML(conn, xml); + if (dom == NULL) { + CU_DEBUG("Failed to define domain from XML"); + ret = 1; + goto out; + } + } + + if (!domain_online(dom)) + CU_DEBUG("Guest is now offline"); ret = virDomainCreate(dom); + + out: + free(xml); return ret; }

KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1216845120 25200 KR> # Node ID 9669e9cfbf6f7645c503a8f337cafe6a70028093 KR> # Parent 427e74d2c45881820ee33b8b6cdeb9cff57a68c0 KR> (#2) Fix a few bugs in the reset() call in CS. This fails to apply for me. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> # HG changeset patch KR> # User Kaitlin Rupert <karupert@us.ibm.com> KR> # Date 1216845120 25200 KR> # Node ID 9669e9cfbf6f7645c503a8f337cafe6a70028093 KR> # Parent 427e74d2c45881820ee33b8b6cdeb9cff57a68c0 KR> (#2) Fix a few bugs in the reset() call in CS.
This fails to apply for me.
It looks like the first version of this patch was applied already. So I'll need to send a follow up patch to fix the issue fixed in this version. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert