Bug 1356461
Summary: | Failed "virsh connect" return 0. | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Yanqiu Zhang <yanqzhan> |
Component: | libvirt | Assignee: | Martin Kletzander <mkletzan> |
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 7.3 | CC: | dyuan, fjin, mzhan, rbalakri, roliga.here, yafu, yanqzhan, zpeng |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | libvirt-2.0.0-4.el7 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2016-11-03 18:48:48 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Yanqiu Zhang
2016-07-14 07:56:18 UTC
To narrow this down the change in return value seems to have appeared between libvirt version 1.3.4 and 1.3.5, and looking through the git logs commit d218344e6c1afce5788d7f72b78859219c50a3de could be a suspect: commit d218344e6c1afce5788d7f72b78859219c50a3de Author: Eric Blake <eblake> Date: Mon Mar 14 14:30:24 2011 -0600 virsh: optimize creation of default connection Ramon de Carvalho Valle reported a problem with: virsh connect qemu:///system as a non-root user. The real root problem appears to be a regression in libvirtd being auto-started on the default qemu:///session URI; however, the symptom points to an independent flaw in virsh - we shouldn't be wasting efforts on making a connection if we aren't going to be using that connection. Fixing virsh avoids Ramon's issue, while I work in the meantime to fix the real libvirtd regression. This patch looks big, but that's because 'gcc -Wmissing-field-initializers' gets triggered by './autobuild.sh --enable-compile-warnings=error', so I had to add 0 initialization to everyone (rather than my preference of just adding the non-zero flags to virshCmds and to cmdConnect). Meanwhile, if you use 'virsh -c URI', the connection must succeed; this patch _only_ optimizes the default connection to be deferred to a later point where we know if a particular command to be run needs a connection. * tools/virsh.c (VSH_CMD_FLAG_NOCONNECT): New flag. (vshCmdDef): Add new flags field. (vshCommandRun): Honor new flag. (domManagementCmds, domMonitoringCmds, storagePoolCmds) (storageVolCmds, networkCmds, nodedevCmds, ifaceCmds) (nwfilterCmds, secretCmds, virshCmds, snapshotCmds) (hostAndHypervisorCmds): Populate new field. (vshReconnect): Don't warn on initial connection. As this suggests, running virsh with a non-default connection using the -c argument does indeed yield the expected results: # virsh -c qemu:///system; echo $? error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory 1 # virsh connect; echo $? error: failed to connect to the hypervisor 0 # virsh -v 1.3.5 'git bisect' points to: commit 0c56d94318393a8295cc0613abb6097a6fd60002 tools: Fix connect command git describe: v1.3.4-2-g0c56d94 contains: v1.3.5-rc1~505 Fixed upstream with v2.1.0-rc1-33-gff498a9ac70a: commit ff498a9ac70a550bed08233a86e00a4faf12aecf Author: Martin Kletzander <mkletzan> Date: Fri Jul 29 08:09:22 2016 +0200 virsh: Report error when explicit connection fails Reproduced with libvirt-2.0.0-2.el7.x86_64. Steps are as comment 0. Verified pass with libvirt-2.0.0-4.el7.x86_64. Test steps: 1.$virsh connect abcd error: failed to connect to the hypervisor error: no connection driver available for abcd 2.Check the return value: $echo $? 1 3.$virsh connect abcd --readonly error: failed to connect to the hypervisor error: no connection driver available for abcd 4.Check the return value: $echo $? 1 5.$virsh connect qemu:///session 6.Check the return value: $echo $? 0 7.$virsh connnect 8.Check the return value: $echo $? 0 9.$virsh "connect abcd; connect; uri" error: failed to connect to the hypervisor error: no connection driver available for abcd qemu:///session 10.Check the return value: $echo $? 0 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-2577.html |