virsh: remove unneeded usage of vshConnectionUsability()

Now that vshCommandRun() checks for the connection automaticaly, remove
all of the redundant checks in the code.

vshConnectionUsability() no longer needs to be exported and this patch
marks it static.
This commit is contained in:
Peter Krempa 2012-08-24 13:57:01 +02:00
parent 70e608918e
commit 67f83cd497
13 changed files with 17 additions and 572 deletions

View File

@ -306,9 +306,6 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR]; struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR];
unsigned int nr_stats, i; unsigned int nr_stats, i;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -365,9 +362,6 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *device = NULL; const char *device = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -426,9 +420,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
details = vshCommandOptBool(cmd, "details"); details = vshCommandOptBool(cmd, "details");
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -530,9 +521,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "inactive")) if (vshCommandOptBool(cmd, "inactive"))
flags |= VIR_DOMAIN_XML_INACTIVE; flags |= VIR_DOMAIN_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -632,9 +620,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd)
xmlNodePtr cur = NULL; xmlNodePtr cur = NULL;
xmlXPathObjectPtr obj = NULL; xmlXPathObjectPtr obj = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -747,9 +732,6 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
virDomainControlInfo info; virDomainControlInfo info;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -843,9 +825,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
bool human = vshCommandOptBool(cmd, "human"); /* human readable output */ bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -968,9 +947,6 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd)
const char *name = NULL, *device = NULL; const char *name = NULL, *device = NULL;
struct _virDomainInterfaceStats stats; struct _virDomainInterfaceStats stats;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -1037,9 +1013,6 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
int count; int count;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -1101,9 +1074,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
char *str, uuid[VIR_UUID_STRING_BUFLEN]; char *str, uuid[VIR_UUID_STRING_BUFLEN];
int has_managed_save = 0; int has_managed_save = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -1233,9 +1203,6 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd)
bool showReason = vshCommandOptBool(cmd, "reason"); bool showReason = vshCommandOptBool(cmd, "reason");
int state, reason; int state, reason;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -1630,9 +1597,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (!optUUID && !optName) if (!optUUID && !optName)
optTable = true; optTable = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(list = vshDomainListCollect(ctl, flags))) if (!(list = vshDomainListCollect(ctl, flags)))
goto cleanup; goto cleanup;

View File

@ -151,9 +151,6 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
int ret; int ret;
unsigned int flags; unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -384,9 +381,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
char *xml; char *xml;
struct stat st; struct stat st;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup; goto cleanup;
@ -623,9 +617,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xml; char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup; goto cleanup;
@ -772,9 +763,6 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd)
const char *name; const char *name;
int autostart; int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -863,9 +851,6 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
goto cleanup; goto cleanup;
@ -1071,9 +1056,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -1186,9 +1168,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
const char *base = NULL; const char *base = NULL;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
goto cleanup; goto cleanup;
@ -1670,9 +1649,6 @@ cmdBlockResize(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
int ret = false; int ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "path", (const char **) &path) < 0) { if (vshCommandOptString(cmd, "path", (const char **) &path) < 0) {
vshError(ctl, "%s", _("Path must not be empty")); vshError(ctl, "%s", _("Path must not be empty"));
return false; return false;
@ -1768,9 +1744,6 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
const char *name = NULL; const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -1830,9 +1803,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
xmlNodePtr cur = NULL; xmlNodePtr cur = NULL;
xmlBufferPtr xml_buf = NULL; xmlBufferPtr xml_buf = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -2017,9 +1987,6 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -2185,9 +2152,6 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd)
const char *name; const char *name;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -2233,9 +2197,6 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
unsigned int suspendTarget; unsigned int suspendTarget;
unsigned long long duration = 0; unsigned long long duration = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -2300,9 +2261,6 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -2406,9 +2364,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
snapshots_safe = true; snapshots_safe = true;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -2716,9 +2671,6 @@ cmdStart(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = VIR_DOMAIN_NONE; unsigned int flags = VIR_DOMAIN_NONE;
int rc; int rc;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME | VSH_BYUUID))) VSH_BYNAME | VSH_BYUUID)))
return false; return false;
@ -2824,9 +2776,6 @@ doSave(void *opaque)
if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
goto out_sig; goto out_sig;
if (!vshConnectionUsability(ctl, ctl->conn))
goto out;
if (vshCommandOptString(cmd, "file", &to) <= 0) if (vshCommandOptString(cmd, "file", &to) <= 0)
goto out; goto out;
@ -3033,9 +2982,6 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "security-info")) if (vshCommandOptBool(cmd, "security-info"))
flags |= VIR_DOMAIN_XML_SECURE; flags |= VIR_DOMAIN_XML_SECURE;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &file) <= 0) if (vshCommandOptString(cmd, "file", &file) <= 0)
return false; return false;
@ -3083,9 +3029,6 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "paused")) if (vshCommandOptBool(cmd, "paused"))
flags |= VIR_DOMAIN_SAVE_PAUSED; flags |= VIR_DOMAIN_SAVE_PAUSED;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &file) <= 0) if (vshCommandOptString(cmd, "file", &file) <= 0)
return false; return false;
@ -3148,9 +3091,6 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &file) <= 0) if (vshCommandOptString(cmd, "file", &file) <= 0)
return false; return false;
@ -3210,9 +3150,6 @@ doManagedsave(void *opaque)
if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
goto out_sig; goto out_sig;
if (!vshConnectionUsability(ctl, ctl->conn))
goto out;
if (vshCommandOptBool(cmd, "bypass-cache")) if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE; flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
if (vshCommandOptBool(cmd, "running")) if (vshCommandOptBool(cmd, "running"))
@ -3304,9 +3241,6 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
int hassave; int hassave;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -3477,9 +3411,6 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -3602,9 +3533,6 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
const char *xmlfile = NULL; const char *xmlfile = NULL;
char *xml = NULL; char *xml = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -3679,9 +3607,6 @@ doDump(void *opaque)
if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
goto out_sig; goto out_sig;
if (!vshConnectionUsability(ctl, ctl->conn))
goto out;
if (vshCommandOptString(cmd, "file", &to) <= 0) if (vshCommandOptString(cmd, "file", &to) <= 0)
goto out; goto out;
@ -3787,11 +3712,6 @@ vshGenFileName(vshControl *ctl, virDomainPtr dom, const char *mime)
const char *ext = NULL; const char *ext = NULL;
char *ret = NULL; char *ret = NULL;
/* We should be already connected, but doesn't
* hurt to check */
if (!vshConnectionUsability(ctl, ctl->conn))
return NULL;
if (!dom) { if (!dom) {
vshError(ctl, "%s", _("Invalid domain supplied")); vshError(ctl, "%s", _("Invalid domain supplied"));
return NULL; return NULL;
@ -3831,9 +3751,6 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
bool generated = false; bool generated = false;
char *mime = NULL; char *mime = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", (const char **) &file) < 0) { if (vshCommandOptString(cmd, "file", (const char **) &file) < 0) {
vshError(ctl, "%s", _("file must not be empty")); vshError(ctl, "%s", _("file must not be empty"));
return false; return false;
@ -3923,9 +3840,6 @@ cmdResume(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -3965,9 +3879,6 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
int flags = 0; int flags = 0;
int rv; int rv;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "mode", &mode) < 0) { if (vshCommandOptString(cmd, "mode", &mode) < 0) {
vshError(ctl, "%s", _("Invalid type")); vshError(ctl, "%s", _("Invalid type"));
return false; return false;
@ -4026,9 +3937,6 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
const char *mode = NULL; const char *mode = NULL;
int flags = 0; int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "mode", &mode) < 0) { if (vshCommandOptString(cmd, "mode", &mode) < 0) {
vshError(ctl, "%s", _("Invalid type")); vshError(ctl, "%s", _("Invalid type"));
return false; return false;
@ -4080,9 +3988,6 @@ cmdReset(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -4118,9 +4023,6 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -4199,9 +4101,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -4237,9 +4136,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
vcpus = virConnectGetMaxVcpus(ctl->conn, type); vcpus = virConnectGetMaxVcpus(ctl->conn, type);
if (vcpus < 0) if (vcpus < 0)
return false; return false;
@ -4321,9 +4217,6 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd)
return false; return false;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -4478,9 +4371,6 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
int n, m; int n, m;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -4653,9 +4543,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
flags = -1; flags = -1;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -4874,9 +4761,6 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
flags = -1; flags = -1;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -5054,9 +4938,6 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
flags = -1; flags = -1;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -5129,9 +5010,6 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
xmlBufferPtr xml_buf = NULL; xmlBufferPtr xml_buf = NULL;
xmlNodePtr node; xmlNodePtr node;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -5232,9 +5110,6 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
int i; int i;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -5332,9 +5207,6 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
bool show_total = false, show_per_cpu = false; bool show_total = false, show_per_cpu = false;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -5494,9 +5366,6 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
#endif #endif
unsigned int flags = VIR_DOMAIN_NONE; unsigned int flags = VIR_DOMAIN_NONE;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -5548,9 +5417,6 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -5596,9 +5462,6 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
int result; int result;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -5677,9 +5540,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -5797,9 +5657,6 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
int ret = true; int ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -5852,9 +5709,6 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
int keycode; int keycode;
unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS]; unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -5944,9 +5798,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
flags = -1; flags = -1;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6025,9 +5876,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
flags = -1; flags = -1;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6140,9 +5988,6 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6316,9 +6161,6 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE; flags |= VIR_DOMAIN_AFFECT_LIVE;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6456,9 +6298,6 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
if (update) if (update)
flags |= VIR_DOMAIN_XML_UPDATE_CPU; flags |= VIR_DOMAIN_XML_UPDATE_CPU;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6499,9 +6338,6 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
char *xmlData; char *xmlData;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "format", &format) < 0 || if (vshCommandOptString(cmd, "format", &format) < 0 ||
vshCommandOptString(cmd, "config", &configFile) < 0) vshCommandOptString(cmd, "config", &configFile) < 0)
return false; return false;
@ -6546,9 +6382,6 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
char *xmlData; char *xmlData;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "format", &format) < 0 if (vshCommandOptString(cmd, "format", &format) < 0
|| vshCommandOptString(cmd, "xml", &xmlFile) < 0) || vshCommandOptString(cmd, "xml", &xmlFile) < 0)
return false; return false;
@ -6587,8 +6420,6 @@ cmdDomname(vshControl *ctl, const vshCmd *cmd)
{ {
virDomainPtr dom; virDomainPtr dom;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYID|VSH_BYUUID))) VSH_BYID|VSH_BYUUID)))
return false; return false;
@ -6618,8 +6449,6 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
unsigned int id; unsigned int id;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYUUID))) VSH_BYNAME|VSH_BYUUID)))
return false; return false;
@ -6653,8 +6482,6 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL,
VSH_BYNAME|VSH_BYID))) VSH_BYNAME|VSH_BYID)))
return false; return false;
@ -6722,9 +6549,6 @@ doMigrate(void *opaque)
if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
goto out_sig; goto out_sig;
if (!vshConnectionUsability(ctl, ctl->conn))
goto out;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto out; goto out;
@ -6904,9 +6728,6 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
long long downtime = 0; long long downtime = 0;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6950,9 +6771,6 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
unsigned long bandwidth = 0; unsigned long bandwidth = 0;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -6992,9 +6810,6 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd)
unsigned long bandwidth; unsigned long bandwidth;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7044,9 +6859,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
int tmp; int tmp;
int flags = 0; int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7211,9 +7023,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
char *doc = NULL; char *doc = NULL;
char *listen_addr = NULL; char *listen_addr = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7278,9 +7087,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
char *doc; char *doc;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7330,9 +7136,6 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7625,9 +7428,6 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
bool funcRet = false; bool funcRet = false;
unsigned int flags; unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7689,9 +7489,6 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
int ret; int ret;
unsigned int flags; unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
@ -7767,9 +7564,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
int functionReturn = false; int functionReturn = false;
unsigned int flags; unsigned int flags;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup; goto cleanup;
@ -8113,9 +7907,6 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
unsigned int flags; unsigned int flags;
xmlNodePtr disk_node = NULL; xmlNodePtr disk_node = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup; goto cleanup;
@ -8182,9 +7973,6 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom_edited = NULL; virDomainPtr dom_edited = NULL;
unsigned int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE; unsigned int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -8301,9 +8089,6 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
if (force) if (force)
flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE; flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup; goto cleanup;

View File

@ -52,9 +52,6 @@ cmdCapabilities(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
char *caps; char *caps;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if ((caps = virConnectGetCapabilities(ctl->conn)) == NULL) { if ((caps = virConnectGetCapabilities(ctl->conn)) == NULL) {
vshError(ctl, "%s", _("failed to get capabilities")); vshError(ctl, "%s", _("failed to get capabilities"));
return false; return false;
@ -149,10 +146,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if ( (cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) { if ( (cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) {
vshError(ctl, "%s", _("cell number has to be a number")); vshError(ctl, "%s", _("cell number has to be a number"));
goto cleanup; goto cleanup;
@ -259,9 +252,6 @@ cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
virNodeInfo info; virNodeInfo info;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (virNodeGetInfo(ctl->conn, &info) < 0) { if (virNodeGetInfo(ctl->conn, &info) < 0) {
vshError(ctl, "%s", _("failed to get node information")); vshError(ctl, "%s", _("failed to get node information"));
return false; return false;
@ -313,9 +303,6 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
double user_time, sys_time, idle_time, iowait_time, total_time; double user_time, sys_time, idle_time, iowait_time, total_time;
double usage; double usage;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptInt(cmd, "cpu", &cpuNum) < 0) { if (vshCommandOptInt(cmd, "cpu", &cpuNum) < 0) {
vshError(ctl, "%s", _("Invalid value of cpuNum")); vshError(ctl, "%s", _("Invalid value of cpuNum"));
return false; return false;
@ -429,9 +416,6 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
virNodeMemoryStatsPtr params = NULL; virNodeMemoryStatsPtr params = NULL;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptInt(cmd, "cell", &cellNum) < 0) { if (vshCommandOptInt(cmd, "cell", &cellNum) < 0) {
vshError(ctl, "%s", _("Invalid value of cellNum")); vshError(ctl, "%s", _("Invalid value of cellNum"));
return false; return false;
@ -493,9 +477,6 @@ cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd)
long long duration; long long duration;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "target", &target) < 0) { if (vshCommandOptString(cmd, "target", &target) < 0) {
vshError(ctl, _("Invalid target argument")); vshError(ctl, _("Invalid target argument"));
return false; return false;
@ -563,9 +544,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool pad = false; bool pad = false;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -623,9 +601,6 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
unsigned int pid_value; /* API uses unsigned int, not pid_t */ unsigned int pid_value; /* API uses unsigned int, not pid_t */
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (vshCommandOptUInt(cmd, "pid", &pid_value) <= 0) { if (vshCommandOptUInt(cmd, "pid", &pid_value) <= 0) {
vshError(ctl, "%s", _("missing pid value")); vshError(ctl, "%s", _("missing pid value"));
goto cleanup; goto cleanup;
@ -679,9 +654,6 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
bool pad = false; bool pad = false;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -752,9 +724,6 @@ cmdSysinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
char *sysinfo; char *sysinfo;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
sysinfo = virConnectGetSysinfo(ctl->conn, 0); sysinfo = virConnectGetSysinfo(ctl->conn, 0);
if (sysinfo == NULL) { if (sysinfo == NULL) {
vshError(ctl, "%s", _("failed to get sysinfo")); vshError(ctl, "%s", _("failed to get sysinfo"));
@ -781,9 +750,6 @@ cmdHostname(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
char *hostname; char *hostname;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
hostname = virConnectGetHostname(ctl->conn); hostname = virConnectGetHostname(ctl->conn);
if (hostname == NULL) { if (hostname == NULL) {
vshError(ctl, "%s", _("failed to get hostname")); vshError(ctl, "%s", _("failed to get hostname"));
@ -810,9 +776,6 @@ cmdURI(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
char *uri; char *uri;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
uri = virConnectGetURI(ctl->conn); uri = virConnectGetURI(ctl->conn);
if (uri == NULL) { if (uri == NULL) {
vshError(ctl, "%s", _("failed to get URI")); vshError(ctl, "%s", _("failed to get URI"));
@ -853,9 +816,6 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
unsigned int minor; unsigned int minor;
unsigned int rel; unsigned int rel;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
hvType = virConnectGetType(ctl->conn); hvType = virConnectGetType(ctl->conn);
if (hvType == NULL) { if (hvType == NULL) {
vshError(ctl, "%s", _("failed to get hypervisor type")); vshError(ctl, "%s", _("failed to get hypervisor type"));

View File

@ -101,9 +101,6 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd)
virInterfacePtr iface_edited = NULL; virInterfacePtr iface_edited = NULL;
unsigned int flags = VIR_INTERFACE_XML_INACTIVE; unsigned int flags = VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
iface = vshCommandOptInterface(ctl, cmd, NULL); iface = vshCommandOptInterface(ctl, cmd, NULL);
if (iface == NULL) if (iface == NULL)
goto cleanup; goto cleanup;
@ -158,9 +155,6 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
char **activeNames = NULL, **inactiveNames = NULL; char **activeNames = NULL, **inactiveNames = NULL;
inactive |= all; inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (active) { if (active) {
maxactive = virConnectNumOfInterfaces(ctl->conn); maxactive = virConnectNumOfInterfaces(ctl->conn);
if (maxactive < 0) { if (maxactive < 0) {
@ -265,8 +259,6 @@ cmdInterfaceName(vshControl *ctl, const vshCmd *cmd)
{ {
virInterfacePtr iface; virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
VSH_BYMAC))) VSH_BYMAC)))
return false; return false;
@ -295,8 +287,6 @@ cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd)
{ {
virInterfacePtr iface; virInterfacePtr iface;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL,
VSH_BYNAME))) VSH_BYNAME)))
return false; return false;
@ -333,9 +323,6 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
if (inactive) if (inactive)
flags |= VIR_INTERFACE_XML_INACTIVE; flags |= VIR_INTERFACE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, NULL))) if (!(iface = vshCommandOptInterface(ctl, cmd, NULL)))
return false; return false;
@ -373,9 +360,6 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -417,9 +401,6 @@ cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name))) if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
return false; return false;
@ -455,9 +436,6 @@ cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name))) if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
return false; return false;
@ -493,9 +471,6 @@ cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(iface = vshCommandOptInterface(ctl, cmd, &name))) if (!(iface = vshCommandOptInterface(ctl, cmd, &name)))
return false; return false;
@ -528,9 +503,6 @@ static const vshCmdOptDef opts_interface_begin[] = {
static bool static bool
cmdInterfaceBegin(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdInterfaceBegin(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (virInterfaceChangeBegin(ctl->conn, 0) < 0) { if (virInterfaceChangeBegin(ctl->conn, 0) < 0) {
vshError(ctl, "%s", _("Failed to begin network config change transaction")); vshError(ctl, "%s", _("Failed to begin network config change transaction"));
return false; return false;
@ -556,9 +528,6 @@ static const vshCmdOptDef opts_interface_commit[] = {
static bool static bool
cmdInterfaceCommit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdInterfaceCommit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (virInterfaceChangeCommit(ctl->conn, 0) < 0) { if (virInterfaceChangeCommit(ctl->conn, 0) < 0) {
vshError(ctl, "%s", _("Failed to commit network config change transaction")); vshError(ctl, "%s", _("Failed to commit network config change transaction"));
return false; return false;
@ -584,9 +553,6 @@ static const vshCmdOptDef opts_interface_rollback[] = {
static bool static bool
cmdInterfaceRollback(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdInterfaceRollback(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (virInterfaceChangeRollback(ctl->conn, 0) < 0) { if (virInterfaceChangeRollback(ctl->conn, 0) < 0) {
vshError(ctl, "%s", _("Failed to rollback network config change transaction")); vshError(ctl, "%s", _("Failed to rollback network config change transaction"));
return false; return false;
@ -631,9 +597,6 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd)
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlNodePtr top_node, br_node, if_node, cur; xmlNodePtr top_node, br_node, if_node, cur;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
/* Get a handle to the original device */ /* Get a handle to the original device */
if (!(if_handle = vshCommandOptInterfaceBy(ctl, cmd, "interface", if (!(if_handle = vshCommandOptInterfaceBy(ctl, cmd, "interface",
&if_name, VSH_BYNAME))) { &if_name, VSH_BYNAME))) {
@ -848,9 +811,6 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd)
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlNodePtr top_node, br_node, if_node, cur; xmlNodePtr top_node, br_node, if_node, cur;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
/* Get a handle to the original device */ /* Get a handle to the original device */
if (!(br_handle = vshCommandOptInterfaceBy(ctl, cmd, "bridge", if (!(br_handle = vshCommandOptInterfaceBy(ctl, cmd, "bridge",
&br_name, VSH_BYNAME))) { &br_name, VSH_BYNAME))) {

View File

@ -100,9 +100,6 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
const char *name; const char *name;
int autostart; int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
return false; return false;
@ -148,9 +145,6 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -193,9 +187,6 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -237,9 +228,6 @@ cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
return false; return false;
@ -278,9 +266,6 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = 0; unsigned int flags = 0;
int inactive; int inactive;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, NULL))) if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
return false; return false;
@ -325,9 +310,6 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd)
int active = -1; int active = -1;
char *bridge = NULL; char *bridge = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, NULL))) if (!(network = vshCommandOptNetwork(ctl, cmd, NULL)))
return false; return false;
@ -385,9 +367,6 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
char **activeNames = NULL, **inactiveNames = NULL; char **activeNames = NULL, **inactiveNames = NULL;
inactive |= all; inactive |= all;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (active) { if (active) {
maxactive = virConnectNumOfNetworks(ctl->conn); maxactive = virConnectNumOfNetworks(ctl->conn);
if (maxactive < 0) { if (maxactive < 0) {
@ -505,8 +484,6 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
{ {
virNetworkPtr network; virNetworkPtr network;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYUUID))) VSH_BYUUID)))
return false; return false;
@ -537,9 +514,6 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name = NULL; const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
return false; return false;
@ -574,9 +548,6 @@ cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) if (!(network = vshCommandOptNetwork(ctl, cmd, &name)))
return false; return false;
@ -611,9 +582,6 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd)
virNetworkPtr network; virNetworkPtr network;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL,
VSH_BYNAME))) VSH_BYNAME)))
return false; return false;
@ -664,9 +632,6 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd)
virNetworkPtr network = NULL; virNetworkPtr network = NULL;
virNetworkPtr network_edited = NULL; virNetworkPtr network_edited = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
network = vshCommandOptNetwork(ctl, cmd, NULL); network = vshCommandOptNetwork(ctl, cmd, NULL);
if (network == NULL) if (network == NULL)
goto cleanup; goto cleanup;

View File

@ -63,9 +63,6 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -111,10 +108,6 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name = NULL; const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn)) {
return false;
}
if (vshCommandOptString(cmd, "name", &name) <= 0) if (vshCommandOptString(cmd, "name", &name) <= 0)
return false; return false;
@ -169,9 +162,6 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
bool tree = vshCommandOptBool(cmd, "tree"); bool tree = vshCommandOptBool(cmd, "tree");
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "cap", &cap) <= 0) if (vshCommandOptString(cmd, "cap", &cap) <= 0)
cap = NULL; cap = NULL;
@ -249,8 +239,6 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
virNodeDevicePtr device; virNodeDevicePtr device;
char *xml; char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "device", &name) <= 0) if (vshCommandOptString(cmd, "device", &name) <= 0)
return false; return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
@ -292,8 +280,6 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd)
virNodeDevicePtr device; virNodeDevicePtr device;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "device", &name) <= 0) if (vshCommandOptString(cmd, "device", &name) <= 0)
return false; return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
@ -335,8 +321,6 @@ cmdNodeDeviceReAttach(vshControl *ctl, const vshCmd *cmd)
virNodeDevicePtr device; virNodeDevicePtr device;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "device", &name) <= 0) if (vshCommandOptString(cmd, "device", &name) <= 0)
return false; return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {
@ -376,8 +360,6 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd)
virNodeDevicePtr device; virNodeDevicePtr device;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "device", &name) <= 0) if (vshCommandOptString(cmd, "device", &name) <= 0)
return false; return false;
if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) {

View File

@ -99,9 +99,6 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -143,9 +140,6 @@ cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name))) if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name)))
return false; return false;
@ -181,9 +175,6 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *dump; char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL))) if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL)))
return false; return false;
@ -219,9 +210,6 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
char **names; char **names;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
numfilters = virConnectNumOfNWFilters(ctl->conn); numfilters = virConnectNumOfNWFilters(ctl->conn);
if (numfilters < 0) { if (numfilters < 0) {
vshError(ctl, "%s", _("Failed to list network filters")); vshError(ctl, "%s", _("Failed to list network filters"));
@ -286,9 +274,6 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
virNWFilterPtr nwfilter = NULL; virNWFilterPtr nwfilter = NULL;
virNWFilterPtr nwfilter_edited = NULL; virNWFilterPtr nwfilter_edited = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL); nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL);
if (nwfilter == NULL) if (nwfilter == NULL)
goto cleanup; goto cleanup;

View File

@ -96,9 +96,6 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
const char *name; const char *name;
int autostart; int autostart;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -145,9 +142,6 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -261,9 +255,6 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
char *xml; char *xml;
bool printXML = vshCommandOptBool(cmd, "print-xml"); bool printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!buildPoolXML(cmd, &name, &xml)) if (!buildPoolXML(cmd, &name, &xml))
return false; return false;
@ -307,9 +298,6 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -347,9 +335,6 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
char *xml; char *xml;
bool printXML = vshCommandOptBool(cmd, "print-xml"); bool printXML = vshCommandOptBool(cmd, "print-xml");
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!buildPoolXML(cmd, &name, &xml)) if (!buildPoolXML(cmd, &name, &xml))
return false; return false;
@ -395,9 +380,6 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd)
const char *name; const char *name;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -443,9 +425,6 @@ cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -481,9 +460,6 @@ cmdPoolDelete(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -519,9 +495,6 @@ cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -563,9 +536,6 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
if (inactive) if (inactive)
flags |= VIR_STORAGE_XML_INACTIVE; flags |= VIR_STORAGE_XML_INACTIVE;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false; return false;
@ -626,10 +596,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
bool active = !inactive || all; bool active = !inactive || all;
inactive |= all; inactive |= all;
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
/* Retrieve the number of active storage pools */ /* Retrieve the number of active storage pools */
if (active) { if (active) {
numActivePools = virConnectNumOfStoragePools(ctl->conn); numActivePools = virConnectNumOfStoragePools(ctl->conn);
@ -1024,9 +990,6 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (host) { if (host) {
const char *port = NULL; const char *port = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
@ -1097,9 +1060,6 @@ cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
return false; return false;
} }
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (srcSpecFile && virFileReadAll(srcSpecFile, VSH_MAX_XML_FILE, if (srcSpecFile && virFileReadAll(srcSpecFile, VSH_MAX_XML_FILE,
&srcSpec) < 0) &srcSpec) < 0)
return false; return false;
@ -1140,9 +1100,6 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false; return false;
@ -1233,8 +1190,6 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd)
{ {
virStoragePoolPtr pool; virStoragePoolPtr pool;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYUUID))) VSH_BYUUID)))
return false; return false;
@ -1265,9 +1220,6 @@ cmdPoolStart(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name = NULL; const char *name = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -1303,9 +1255,6 @@ cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name)))
return false; return false;
@ -1340,9 +1289,6 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
virStoragePoolPtr pool; virStoragePoolPtr pool;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME))) VSH_BYNAME)))
return false; return false;
@ -1379,9 +1325,6 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd)
unsigned int flags = VIR_STORAGE_XML_INACTIVE; unsigned int flags = VIR_STORAGE_XML_INACTIVE;
char *tmp_desc = NULL; char *tmp_desc = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
pool = vshCommandOptPool(ctl, cmd, "pool", NULL); pool = vshCommandOptPool(ctl, cmd, "pool", NULL);
if (pool == NULL) if (pool == NULL)
goto cleanup; goto cleanup;

View File

@ -87,9 +87,6 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
virSecretPtr res; virSecretPtr res;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptString(cmd, "file", &from) <= 0) if (vshCommandOptString(cmd, "file", &from) <= 0)
return false; return false;
@ -134,9 +131,6 @@ cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
char *xml; char *xml;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
secret = vshCommandOptSecret(ctl, cmd, NULL); secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL) if (secret == NULL)
return false; return false;
@ -178,9 +172,6 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
int res; int res;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
secret = vshCommandOptSecret(ctl, cmd, NULL); secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL) if (secret == NULL)
return false; return false;
@ -236,9 +227,6 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
size_t value_size; size_t value_size;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
secret = vshCommandOptSecret(ctl, cmd, NULL); secret = vshCommandOptSecret(ctl, cmd, NULL);
if (secret == NULL) if (secret == NULL)
return false; return false;
@ -286,9 +274,6 @@ cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
const char *uuid; const char *uuid;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
secret = vshCommandOptSecret(ctl, cmd, &uuid); secret = vshCommandOptSecret(ctl, cmd, &uuid);
if (secret == NULL) if (secret == NULL)
return false; return false;
@ -320,9 +305,6 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
int maxuuids = 0, i; int maxuuids = 0, i;
char **uuids = NULL; char **uuids = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
maxuuids = virConnectNumOfSecrets(ctl->conn); maxuuids = virConnectNumOfSecrets(ctl->conn);
if (maxuuids < 0) { if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets")); vshError(ctl, "%s", _("Failed to list secrets"));

View File

@ -156,9 +156,6 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "atomic")) if (vshCommandOptBool(cmd, "atomic"))
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC; flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -296,9 +293,6 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "atomic")) if (vshCommandOptBool(cmd, "atomic"))
flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC; flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -429,9 +423,6 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd)
vshCommandOptBool(cmd, "snapshotname")) vshCommandOptBool(cmd, "snapshotname"))
define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT; define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -532,9 +523,6 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "security-info")) if (vshCommandOptBool(cmd, "security-info"))
flags |= VIR_DOMAIN_XML_SECURE; flags |= VIR_DOMAIN_XML_SECURE;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, &domname); dom = vshCommandOptDomain(ctl, cmd, &domname);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -701,9 +689,6 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd)
int current; int current;
int metadata; int metadata;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
return false; return false;
@ -1183,9 +1168,6 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
virDomainSnapshotPtr start = NULL; virDomainSnapshotPtr start = NULL;
vshSnapshotListPtr snaplist = NULL; vshSnapshotListPtr snaplist = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -1381,9 +1363,6 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "security-info")) if (vshCommandOptBool(cmd, "security-info"))
flags |= VIR_DOMAIN_XML_SECURE; flags |= VIR_DOMAIN_XML_SECURE;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -1438,9 +1417,6 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd)
virDomainSnapshotPtr snapshot = NULL; virDomainSnapshotPtr snapshot = NULL;
char *parent = NULL; char *parent = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -1511,9 +1487,6 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "force")) if (vshCommandOptBool(cmd, "force"))
force = true; force = true;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;
@ -1572,9 +1545,6 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd)
virDomainSnapshotPtr snapshot = NULL; virDomainSnapshotPtr snapshot = NULL;
unsigned int flags = 0; unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
dom = vshCommandOptDomain(ctl, cmd, NULL); dom = vshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL) if (dom == NULL)
goto cleanup; goto cleanup;

View File

@ -147,9 +147,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
unsigned long long capacity, allocation = 0; unsigned long long capacity, allocation = 0;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME))) VSH_BYNAME)))
return false; return false;
@ -302,9 +299,6 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *buffer; char *buffer;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL,
VSH_BYNAME))) VSH_BYNAME)))
return false; return false;
@ -361,9 +355,6 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
bool ret = false; bool ret = false;
char *buffer = NULL; char *buffer = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
goto cleanup; goto cleanup;
@ -456,9 +447,6 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
xmlChar *newxml = NULL; xmlChar *newxml = NULL;
bool ret = false; bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
goto cleanup; goto cleanup;
@ -544,9 +532,6 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
const char *name = NULL; const char *name = NULL;
unsigned long long offset = 0, length = 0; unsigned long long offset = 0, length = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) { if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer")); vshError(ctl, _("Unable to parse integer"));
return false; return false;
@ -634,9 +619,6 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
unsigned long long offset = 0, length = 0; unsigned long long offset = 0, length = 0;
bool created = false; bool created = false;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) { if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) {
vshError(ctl, _("Unable to parse integer")); vshError(ctl, _("Unable to parse integer"));
return false; return false;
@ -722,9 +704,6 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
const char *name; const char *name;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
return false; return false;
} }
@ -771,9 +750,6 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO; int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
int funcRet; int funcRet;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) {
return false; return false;
} }
@ -829,9 +805,6 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd)
virStorageVolPtr vol; virStorageVolPtr vol;
bool ret = true; bool ret = true;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false; return false;
@ -915,9 +888,6 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "shrink")) if (vshCommandOptBool(cmd, "shrink"))
flags |= VIR_STORAGE_VOL_RESIZE_SHRINK; flags |= VIR_STORAGE_VOL_RESIZE_SHRINK;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false; return false;
@ -981,9 +951,6 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
bool ret = true; bool ret = true;
char *dump; char *dump;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false; return false;
@ -1039,10 +1006,6 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}; };
struct volInfoText *volInfoTexts = NULL; struct volInfoText *volInfoTexts = NULL;
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
/* Look up the pool information given to us by the user */ /* Look up the pool information given to us by the user */
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false; return false;
@ -1315,9 +1278,6 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd)
{ {
virStorageVolPtr vol; virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
VSH_BYUUID))) VSH_BYUUID)))
return false; return false;
@ -1349,10 +1309,6 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd)
virStorageVolPtr vol; virStorageVolPtr vol;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
/* Check the connection to libvirtd daemon is still working */
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
/* Use the supplied string to locate the volume */ /* Use the supplied string to locate the volume */
if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL,
VSH_BYUUID))) { VSH_BYUUID))) {
@ -1403,9 +1359,6 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd)
{ {
virStorageVolPtr vol; virStorageVolPtr vol;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL)))
return false; return false;
@ -1435,9 +1388,6 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd)
virStorageVolPtr vol; virStorageVolPtr vol;
char * StorageVolPath; char * StorageVolPath;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) { if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) {
return false; return false;
} }

View File

@ -1465,6 +1465,23 @@ vshCmdHasOption(vshControl *ctl, const vshCmd *cmd, const char *optname)
return found; return found;
} }
static bool
vshConnectionUsability(vshControl *ctl, virConnectPtr conn)
{
if (!conn ||
virConnectIsAlive(conn) == 0) {
vshError(ctl, "%s", _("no valid connection"));
return false;
}
/* The connection is considered dead only if
* virConnectIsAlive() successfuly says so.
*/
vshResetLibvirtError();
return true;
}
/* /*
* Executes command(s) and returns return code from last command * Executes command(s) and returns return code from last command
*/ */
@ -1951,23 +1968,6 @@ vshFindTypedParamByName(const char *name, virTypedParameterPtr list, int count)
return NULL; return NULL;
} }
bool
vshConnectionUsability(vshControl *ctl, virConnectPtr conn)
{
if (!conn ||
virConnectIsAlive(conn) == 0) {
vshError(ctl, "%s", _("no valid connection"));
return false;
}
/* The connection is considered dead only if
* virConnectIsAlive() successfuly says so.
*/
vshResetLibvirtError();
return true;
}
void void
vshDebug(vshControl *ctl, int level, const char *format, ...) vshDebug(vshControl *ctl, int level, const char *format, ...)
{ {

View File

@ -315,7 +315,6 @@ void vshDebug(vshControl *ctl, int level, const char *format, ...)
int vshNameSorter(const void *a, const void *b); int vshNameSorter(const void *a, const void *b);
int vshDomainState(vshControl *ctl, virDomainPtr dom, int *reason); int vshDomainState(vshControl *ctl, virDomainPtr dom, int *reason);
bool vshConnectionUsability(vshControl *ctl, virConnectPtr conn);
virTypedParameterPtr vshFindTypedParamByName(const char *name, virTypedParameterPtr vshFindTypedParamByName(const char *name,
virTypedParameterPtr list, virTypedParameterPtr list,
int count); int count);