Bug 489283

Summary: virsh save $shutted-off-domain will get invalid domain pointer in no domain with matching id -1
Product: Red Hat Enterprise Linux 5 Reporter: Vivian Bian <vbian>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 5.4CC: berrange, cpelland, llim, nzhang, ovirt-maint, virt-maint, xen-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-02 09:23:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Vivian Bian 2009-03-09 10:33:59 UTC
Description of problem:
try to save a domain which is shutted off will get an error

Version-Release number of selected component (if applicable):
ovirt-node-image-1.0-1.snap3.el5ovirt

How reproducible:
Always

Steps to Reproduce:
1. # virsh define xxx.xml
2. # virsh save $domain_name $file_name (this domain is a shut off one)
  
Actual results:
libvir: QEMU error: invalid domain pointer in no domain with matching id -1
error: Failed to save domain super_disk5 to example

Expected results:
the domain could be saved successfully

Additional info:
a running domain could be saved well

Comment 1 Daniel Berrangé 2009-03-09 11:09:54 UTC
This is merely a mis-leading error message. The 'save' operation is intended to fail for inactive domains, since there is no VM to save. We should give a better error message though.

The problem is in the QEMU driver which does

    qemuDriverLock(driver);
    vm = virDomainFindByID(&driver->domains, dom->id);

    if (!vm) {
        qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
                         _("no domain with matching id %d"), dom->id);
        goto cleanup;
    }

    if (!virDomainIsActive(vm)) {
        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
                         "%s", _("domain is not running"));
        goto cleanup;
    }

It never gets to the 'IsActive' check because the lookup-by-ID fails first. We should really never do a lookup-by-ID in the driver. If we switched this code to use virDomainFindByUUID, then the second more useful error message would be returned.

Comment 2 Perry Myers 2009-03-31 03:19:38 UTC
Moving to RHEL since libvirt is not supported in RHEV1.0 production builds and this problem will need to be addressed in RHEL5.4 release

Comment 3 Daniel Veillard 2009-04-23 15:23:42 UTC
Note that with Xen as the hypervisor the output is correct:

[root@test2 ~]# virsh save test /tmp/test.mem
error: Failed to save domain test to /tmp/test.mem
error: invalid argument in Domain test isn't running.

[root@test2 ~]# 

Once rebooted to use KVM instead the error shows up:

[root@test2 ~]# virsh save kvmtest /tmp/kvmtest.mem
error: Failed to save domain kvmtest to /tmp/kvmtest.mem
error: invalid domain pointer in no domain with matching id -1

[root@test2 ~]# 

but the ID -> UUID lookup has been implemented upstream so in
the final version with libvirt-0.6.3 this should be fixed:


[root@test2 ~]# virsh save kvmtest /tmp/kvmtest.mem
error: Failed to save domain kvmtest to /tmp/kvmtest.mem
error: operation failed: domain is not running

[root@test2 ~]# 

  This will be modified as soon as 0.6.3 is pushed,

Daniel

Comment 4 Daniel Veillard 2009-04-28 10:06:16 UTC
Modified with push of libvirt-0.6.3-1.el5 in dist-5E-qu-candidate

Daniel

Comment 7 Nan Zhang 2009-05-27 11:50:09 UTC
This has been verified in libvirt 0.6.3-3 on rhel-5.4. Already fixed.

Verified steps:

# virsh list --all
 Id Name                 State
----------------------------------
  - demo                 shut off

# virsh save demo test123
error: Failed to save domain demo to test123
error: operation failed: domain is not running

Comment 9 errata-xmlrpc 2009-09-02 09:23:33 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1269.html