• E
    virsh: optimize creation of default connection · d218344e
    Eric Blake 提交于
    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.
    d218344e
virsh.c 368.3 KB