diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/virsh-domain-monitor.c | 36 | ||||
-rw-r--r-- | tools/virsh-domain.c | 215 | ||||
-rw-r--r-- | tools/virsh-host.c | 40 | ||||
-rw-r--r-- | tools/virsh-interface.c | 40 | ||||
-rw-r--r-- | tools/virsh-network.c | 35 | ||||
-rw-r--r-- | tools/virsh-nodedev.c | 18 | ||||
-rw-r--r-- | tools/virsh-nwfilter.c | 15 | ||||
-rw-r--r-- | tools/virsh-pool.c | 57 | ||||
-rw-r--r-- | tools/virsh-secret.c | 18 | ||||
-rw-r--r-- | tools/virsh-snapshot.c | 30 | ||||
-rw-r--r-- | tools/virsh-volume.c | 50 | ||||
-rw-r--r-- | tools/virsh.c | 34 | ||||
-rw-r--r-- | tools/virsh.h | 1 |
13 files changed, 17 insertions, 572 deletions
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 44f65adc2..7e252d288 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -306,9 +306,6 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR]; unsigned int nr_stats, i; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -365,9 +362,6 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *device = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -426,9 +420,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) details = vshCommandOptBool(cmd, "details"); - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -530,9 +521,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "inactive")) flags |= VIR_DOMAIN_XML_INACTIVE; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -632,9 +620,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) xmlNodePtr cur = NULL; xmlXPathObjectPtr obj = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -747,9 +732,6 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd) bool ret = true; virDomainControlInfo info; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -843,9 +825,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) bool ret = false; bool human = vshCommandOptBool(cmd, "human"); /* human readable output */ - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -968,9 +947,6 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) const char *name = NULL, *device = NULL; struct _virDomainInterfaceStats stats; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -1037,9 +1013,6 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd) int count; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -1101,9 +1074,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) char *str, uuid[VIR_UUID_STRING_BUFLEN]; int has_managed_save = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -1233,9 +1203,6 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd) bool showReason = vshCommandOptBool(cmd, "reason"); int state, reason; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -1630,9 +1597,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) if (!optUUID && !optName) optTable = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(list = vshDomainListCollect(ctl, flags))) goto cleanup; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3ecc52e12..f0ec742aa 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -151,9 +151,6 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) int ret; unsigned int flags; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -384,9 +381,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) char *xml; struct stat st; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; @@ -623,9 +617,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virBuffer buf = VIR_BUFFER_INITIALIZER; char *xml; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; @@ -772,9 +763,6 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd) const char *name; int autostart; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -863,9 +851,6 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) goto cleanup; @@ -1071,9 +1056,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -1186,9 +1168,6 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd, const char *base = NULL; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) goto cleanup; @@ -1670,9 +1649,6 @@ cmdBlockResize(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; int ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "path", (const char **) &path) < 0) { vshError(ctl, "%s", _("Path must not be empty")); return false; @@ -1768,9 +1744,6 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; const char *name = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -1830,9 +1803,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) xmlNodePtr cur = NULL; xmlBufferPtr xml_buf = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -2017,9 +1987,6 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -2185,9 +2152,6 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd) const char *name; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -2233,9 +2197,6 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) unsigned int suspendTarget; unsigned long long duration = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -2300,9 +2261,6 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd) bool ret = false; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -2406,9 +2364,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) snapshots_safe = true; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -2716,9 +2671,6 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) unsigned int flags = VIR_DOMAIN_NONE; int rc; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, VSH_BYNAME | VSH_BYUUID))) return false; @@ -2824,9 +2776,6 @@ doSave(void *opaque) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto out; - if (vshCommandOptString(cmd, "file", &to) <= 0) goto out; @@ -3033,9 +2982,6 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |= VIR_DOMAIN_XML_SECURE; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &file) <= 0) return false; @@ -3083,9 +3029,6 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "paused")) flags |= VIR_DOMAIN_SAVE_PAUSED; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &file) <= 0) return false; @@ -3148,9 +3091,6 @@ cmdSaveImageEdit(vshControl *ctl, const vshCmd *cmd) return false; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &file) <= 0) return false; @@ -3210,9 +3150,6 @@ doManagedsave(void *opaque) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto out; - if (vshCommandOptBool(cmd, "bypass-cache")) flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE; if (vshCommandOptBool(cmd, "running")) @@ -3304,9 +3241,6 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd) bool ret = false; int hassave; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -3477,9 +3411,6 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -3602,9 +3533,6 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) const char *xmlfile = NULL; char *xml = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -3679,9 +3607,6 @@ doDump(void *opaque) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto out; - if (vshCommandOptString(cmd, "file", &to) <= 0) goto out; @@ -3787,11 +3712,6 @@ vshGenFileName(vshControl *ctl, virDomainPtr dom, const char *mime) const char *ext = NULL; char *ret = NULL; - /* We should be already connected, but doesn't - * hurt to check */ - if (!vshConnectionUsability(ctl, ctl->conn)) - return NULL; - if (!dom) { vshError(ctl, "%s", _("Invalid domain supplied")); return NULL; @@ -3831,9 +3751,6 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd) bool generated = false; char *mime = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", (const char **) &file) < 0) { vshError(ctl, "%s", _("file must not be empty")); return false; @@ -3923,9 +3840,6 @@ cmdResume(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -3965,9 +3879,6 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) int flags = 0; int rv; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "mode", &mode) < 0) { vshError(ctl, "%s", _("Invalid type")); return false; @@ -4026,9 +3937,6 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) const char *mode = NULL; int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "mode", &mode) < 0) { vshError(ctl, "%s", _("Invalid type")); return false; @@ -4080,9 +3988,6 @@ cmdReset(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -4118,9 +4023,6 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -4199,9 +4101,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -4237,9 +4136,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) return false; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - vcpus = virConnectGetMaxVcpus(ctl->conn, type); if (vcpus < 0) return false; @@ -4321,9 +4217,6 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) return false; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -4478,9 +4371,6 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) bool ret = true; int n, m; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -4653,9 +4543,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) flags = -1; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -4874,9 +4761,6 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) flags = -1; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -5054,9 +4938,6 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) flags = -1; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -5129,9 +5010,6 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) xmlBufferPtr xml_buf = NULL; xmlNodePtr node; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -5232,9 +5110,6 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) virBuffer buf = VIR_BUFFER_INITIALIZER; int i; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -5332,9 +5207,6 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) bool show_total = false, show_per_cpu = false; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -5494,9 +5366,6 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) #endif unsigned int flags = VIR_DOMAIN_NONE; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -5548,9 +5417,6 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -5596,9 +5462,6 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; int result; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -5677,9 +5540,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -5797,9 +5657,6 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; int ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -5852,9 +5709,6 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) int keycode; unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -5944,9 +5798,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) flags = -1; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6025,9 +5876,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) flags = -1; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6140,9 +5988,6 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6316,9 +6161,6 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd) flags |= VIR_DOMAIN_AFFECT_LIVE; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6456,9 +6298,6 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) if (update) flags |= VIR_DOMAIN_XML_UPDATE_CPU; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6499,9 +6338,6 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd) char *xmlData; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "format", &format) < 0 || vshCommandOptString(cmd, "config", &configFile) < 0) return false; @@ -6546,9 +6382,6 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd) char *xmlData; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "format", &format) < 0 || vshCommandOptString(cmd, "xml", &xmlFile) < 0) return false; @@ -6587,8 +6420,6 @@ cmdDomname(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, VSH_BYID|VSH_BYUUID))) return false; @@ -6618,8 +6449,6 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; unsigned int id; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, VSH_BYNAME|VSH_BYUUID))) return false; @@ -6653,8 +6482,6 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(dom = vshCommandOptDomainBy(ctl, cmd, NULL, VSH_BYNAME|VSH_BYID))) return false; @@ -6722,9 +6549,6 @@ doMigrate(void *opaque) if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0) goto out_sig; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto out; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) goto out; @@ -6904,9 +6728,6 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd) long long downtime = 0; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6950,9 +6771,6 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd) unsigned long bandwidth = 0; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -6992,9 +6810,6 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd) unsigned long bandwidth; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7044,9 +6859,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) int tmp; int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7211,9 +7023,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) char *doc = NULL; char *listen_addr = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7278,9 +7087,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) bool ret = false; char *doc; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7330,9 +7136,6 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7625,9 +7428,6 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) bool funcRet = false; unsigned int flags; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7689,9 +7489,6 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) int ret; unsigned int flags; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -7767,9 +7564,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) int functionReturn = false; unsigned int flags; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; @@ -8113,9 +7907,6 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) unsigned int flags; xmlNodePtr disk_node = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; @@ -8182,9 +7973,6 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom_edited = NULL; unsigned int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -8301,9 +8089,6 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) if (force) flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) goto cleanup; diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 2f3b41399..c46288b61 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -52,9 +52,6 @@ cmdCapabilities(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { char *caps; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if ((caps = virConnectGetCapabilities(ctl->conn)) == NULL) { vshError(ctl, "%s", _("failed to get capabilities")); return false; @@ -149,10 +146,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) xmlDocPtr xml = NULL; xmlXPathContextPtr ctxt = NULL; - - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if ( (cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) { vshError(ctl, "%s", _("cell number has to be a number")); goto cleanup; @@ -259,9 +252,6 @@ cmdNodeinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { virNodeInfo info; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (virNodeGetInfo(ctl->conn, &info) < 0) { vshError(ctl, "%s", _("failed to get node information")); return false; @@ -313,9 +303,6 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) double user_time, sys_time, idle_time, iowait_time, total_time; double usage; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptInt(cmd, "cpu", &cpuNum) < 0) { vshError(ctl, "%s", _("Invalid value of cpuNum")); return false; @@ -429,9 +416,6 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) virNodeMemoryStatsPtr params = NULL; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptInt(cmd, "cell", &cellNum) < 0) { vshError(ctl, "%s", _("Invalid value of cellNum")); return false; @@ -493,9 +477,6 @@ cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd) long long duration; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "target", &target) < 0) { vshError(ctl, _("Invalid target argument")); return false; @@ -563,9 +544,6 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd) virBuffer buf = VIR_BUFFER_INITIALIZER; bool pad = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -623,9 +601,6 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; 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) { vshError(ctl, "%s", _("missing pid value")); goto cleanup; @@ -679,9 +654,6 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd) virBuffer buf = VIR_BUFFER_INITIALIZER; bool pad = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -752,9 +724,6 @@ cmdSysinfo(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { char *sysinfo; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - sysinfo = virConnectGetSysinfo(ctl->conn, 0); if (sysinfo == NULL) { vshError(ctl, "%s", _("failed to get sysinfo")); @@ -781,9 +750,6 @@ cmdHostname(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { char *hostname; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - hostname = virConnectGetHostname(ctl->conn); if (hostname == NULL) { vshError(ctl, "%s", _("failed to get hostname")); @@ -810,9 +776,6 @@ cmdURI(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { char *uri; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - uri = virConnectGetURI(ctl->conn); if (uri == NULL) { vshError(ctl, "%s", _("failed to get URI")); @@ -853,9 +816,6 @@ cmdVersion(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) unsigned int minor; unsigned int rel; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - hvType = virConnectGetType(ctl->conn); if (hvType == NULL) { vshError(ctl, "%s", _("failed to get hypervisor type")); diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index da02168d8..28e9d8cd7 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -101,9 +101,6 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd) virInterfacePtr iface_edited = NULL; unsigned int flags = VIR_INTERFACE_XML_INACTIVE; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - iface = vshCommandOptInterface(ctl, cmd, NULL); if (iface == NULL) goto cleanup; @@ -158,9 +155,6 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) char **activeNames = NULL, **inactiveNames = NULL; inactive |= all; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (active) { maxactive = virConnectNumOfInterfaces(ctl->conn); if (maxactive < 0) { @@ -265,8 +259,6 @@ cmdInterfaceName(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, VSH_BYMAC))) return false; @@ -295,8 +287,6 @@ cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(iface = vshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, VSH_BYNAME))) return false; @@ -333,9 +323,6 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd) if (inactive) flags |= VIR_INTERFACE_XML_INACTIVE; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(iface = vshCommandOptInterface(ctl, cmd, NULL))) return false; @@ -373,9 +360,6 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -417,9 +401,6 @@ cmdInterfaceUndefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(iface = vshCommandOptInterface(ctl, cmd, &name))) return false; @@ -455,9 +436,6 @@ cmdInterfaceStart(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(iface = vshCommandOptInterface(ctl, cmd, &name))) return false; @@ -493,9 +471,6 @@ cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(iface = vshCommandOptInterface(ctl, cmd, &name))) return false; @@ -528,9 +503,6 @@ static const vshCmdOptDef opts_interface_begin[] = { static bool cmdInterfaceBegin(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (virInterfaceChangeBegin(ctl->conn, 0) < 0) { vshError(ctl, "%s", _("Failed to begin network config change transaction")); return false; @@ -556,9 +528,6 @@ static const vshCmdOptDef opts_interface_commit[] = { static bool cmdInterfaceCommit(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (virInterfaceChangeCommit(ctl->conn, 0) < 0) { vshError(ctl, "%s", _("Failed to commit network config change transaction")); return false; @@ -584,9 +553,6 @@ static const vshCmdOptDef opts_interface_rollback[] = { static bool cmdInterfaceRollback(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (virInterfaceChangeRollback(ctl->conn, 0) < 0) { vshError(ctl, "%s", _("Failed to rollback network config change transaction")); return false; @@ -631,9 +597,6 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) xmlXPathContextPtr ctxt = NULL; xmlNodePtr top_node, br_node, if_node, cur; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - /* Get a handle to the original device */ if (!(if_handle = vshCommandOptInterfaceBy(ctl, cmd, "interface", &if_name, VSH_BYNAME))) { @@ -848,9 +811,6 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) xmlXPathContextPtr ctxt = NULL; xmlNodePtr top_node, br_node, if_node, cur; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - /* Get a handle to the original device */ if (!(br_handle = vshCommandOptInterfaceBy(ctl, cmd, "bridge", &br_name, VSH_BYNAME))) { diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 37fa3bad7..db204af92 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -100,9 +100,6 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd) const char *name; int autostart; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) return false; @@ -148,9 +145,6 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -193,9 +187,6 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -237,9 +228,6 @@ cmdNetworkDestroy(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) return false; @@ -278,9 +266,6 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; int inactive; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetwork(ctl, cmd, NULL))) return false; @@ -325,9 +310,6 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd) int active = -1; char *bridge = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetwork(ctl, cmd, NULL))) return false; @@ -385,9 +367,6 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) char **activeNames = NULL, **inactiveNames = NULL; inactive |= all; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (active) { maxactive = virConnectNumOfNetworks(ctl->conn); if (maxactive < 0) { @@ -505,8 +484,6 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd) { virNetworkPtr network; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, VSH_BYUUID))) return false; @@ -537,9 +514,6 @@ cmdNetworkStart(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) return false; @@ -574,9 +548,6 @@ cmdNetworkUndefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetwork(ctl, cmd, &name))) return false; @@ -611,9 +582,6 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd) virNetworkPtr network; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(network = vshCommandOptNetworkBy(ctl, cmd, NULL, VSH_BYNAME))) return false; @@ -664,9 +632,6 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd) virNetworkPtr network = NULL; virNetworkPtr network_edited = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - network = vshCommandOptNetwork(ctl, cmd, NULL); if (network == NULL) goto cleanup; diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index bcdc3d8f9..e784af123 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -63,9 +63,6 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -111,10 +108,6 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) { - return false; - } - if (vshCommandOptString(cmd, "name", &name) <= 0) return false; @@ -169,9 +162,6 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) bool tree = vshCommandOptBool(cmd, "tree"); bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "cap", &cap) <= 0) cap = NULL; @@ -249,8 +239,6 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) virNodeDevicePtr device; char *xml; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (vshCommandOptString(cmd, "device", &name) <= 0) return false; if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { @@ -292,8 +280,6 @@ cmdNodeDeviceDetach(vshControl *ctl, const vshCmd *cmd) virNodeDevicePtr device; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (vshCommandOptString(cmd, "device", &name) <= 0) return false; if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { @@ -335,8 +321,6 @@ cmdNodeDeviceReAttach(vshControl *ctl, const vshCmd *cmd) virNodeDevicePtr device; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (vshCommandOptString(cmd, "device", &name) <= 0) return false; if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { @@ -376,8 +360,6 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd) virNodeDevicePtr device; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (vshCommandOptString(cmd, "device", &name) <= 0) return false; if (!(device = virNodeDeviceLookupByName(ctl->conn, name))) { diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 5e8f54060..5169d38bf 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -99,9 +99,6 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -143,9 +140,6 @@ cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, &name))) return false; @@ -181,9 +175,6 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *dump; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL))) return false; @@ -219,9 +210,6 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) char **names; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - numfilters = virConnectNumOfNWFilters(ctl->conn); if (numfilters < 0) { vshError(ctl, "%s", _("Failed to list network filters")); @@ -286,9 +274,6 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd) virNWFilterPtr nwfilter = NULL; virNWFilterPtr nwfilter_edited = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - nwfilter = vshCommandOptNWFilter(ctl, cmd, NULL); if (nwfilter == NULL) goto cleanup; diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index d9cba4ef9..fd239d2a9 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -96,9 +96,6 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd) const char *name; int autostart; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -145,9 +142,6 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -261,9 +255,6 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd) char *xml; bool printXML = vshCommandOptBool(cmd, "print-xml"); - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!buildPoolXML(cmd, &name, &xml)) return false; @@ -307,9 +298,6 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -347,9 +335,6 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd) char *xml; bool printXML = vshCommandOptBool(cmd, "print-xml"); - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!buildPoolXML(cmd, &name, &xml)) return false; @@ -395,9 +380,6 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd) const char *name; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -443,9 +425,6 @@ cmdPoolDestroy(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -481,9 +460,6 @@ cmdPoolDelete(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -519,9 +495,6 @@ cmdPoolRefresh(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -563,9 +536,6 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd) if (inactive) flags |= VIR_STORAGE_XML_INACTIVE; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) return false; @@ -626,10 +596,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) bool active = !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 */ if (active) { numActivePools = virConnectNumOfStoragePools(ctl->conn); @@ -1024,9 +990,6 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED) return false; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (host) { const char *port = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -1097,9 +1060,6 @@ cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED) return false; } - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (srcSpecFile && virFileReadAll(srcSpecFile, VSH_MAX_XML_FILE, &srcSpec) < 0) return false; @@ -1140,9 +1100,6 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd) bool ret = true; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) return false; @@ -1233,8 +1190,6 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd) { virStoragePoolPtr pool; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYUUID))) return false; @@ -1265,9 +1220,6 @@ cmdPoolStart(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -1303,9 +1255,6 @@ cmdPoolUndefine(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; @@ -1340,9 +1289,6 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd) virStoragePoolPtr pool; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME))) return false; @@ -1379,9 +1325,6 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd) unsigned int flags = VIR_STORAGE_XML_INACTIVE; char *tmp_desc = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - pool = vshCommandOptPool(ctl, cmd, "pool", NULL); if (pool == NULL) goto cleanup; diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 7247eee1e..abcfdfe37 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -87,9 +87,6 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) virSecretPtr res; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptString(cmd, "file", &from) <= 0) return false; @@ -134,9 +131,6 @@ cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd) bool ret = false; char *xml; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - secret = vshCommandOptSecret(ctl, cmd, NULL); if (secret == NULL) return false; @@ -178,9 +172,6 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) int res; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - secret = vshCommandOptSecret(ctl, cmd, NULL); if (secret == NULL) return false; @@ -236,9 +227,6 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) size_t value_size; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - secret = vshCommandOptSecret(ctl, cmd, NULL); if (secret == NULL) return false; @@ -286,9 +274,6 @@ cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd) bool ret = false; const char *uuid; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - secret = vshCommandOptSecret(ctl, cmd, &uuid); if (secret == NULL) return false; @@ -320,9 +305,6 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) int maxuuids = 0, i; char **uuids = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - maxuuids = virConnectNumOfSecrets(ctl->conn); if (maxuuids < 0) { vshError(ctl, "%s", _("Failed to list secrets")); diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 5d84f7a5f..8d46402f4 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -156,9 +156,6 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "atomic")) flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -296,9 +293,6 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "atomic")) flags |= VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -429,9 +423,6 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) vshCommandOptBool(cmd, "snapshotname")) define_flags |= VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -532,9 +523,6 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |= VIR_DOMAIN_XML_SECURE; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, &domname); if (dom == NULL) goto cleanup; @@ -701,9 +689,6 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd) int current; int metadata; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) return false; @@ -1183,9 +1168,6 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) virDomainSnapshotPtr start = NULL; vshSnapshotListPtr snaplist = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -1381,9 +1363,6 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |= VIR_DOMAIN_XML_SECURE; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -1438,9 +1417,6 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd) virDomainSnapshotPtr snapshot = NULL; char *parent = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -1511,9 +1487,6 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "force")) force = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; @@ -1572,9 +1545,6 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd) virDomainSnapshotPtr snapshot = NULL; unsigned int flags = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) goto cleanup; diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 74ac19d68..6ab271e0b 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -147,9 +147,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) unsigned long long capacity, allocation = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME))) return false; @@ -302,9 +299,6 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *buffer; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(pool = vshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME))) return false; @@ -361,9 +355,6 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) bool ret = false; char *buffer = NULL; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) goto cleanup; @@ -456,9 +447,6 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) xmlChar *newxml = NULL; bool ret = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (!(origvol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) goto cleanup; @@ -544,9 +532,6 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) const char *name = NULL; unsigned long long offset = 0, length = 0; - if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; - if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) { vshError(ctl, _("Unable to parse integer")); return false; @@ -634,9 +619,6 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd) unsigned long long offset = 0, length = 0; bool created = false; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (vshCommandOptULongLong(cmd, "offset", &offset) < 0) { vshError(ctl, _("Unable to parse integer")); return false; @@ -722,9 +704,6 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { return false; } @@ -771,9 +750,6 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO; int funcRet; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { return false; } @@ -829,9 +805,6 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr vol; bool ret = true; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; @@ -915,9 +888,6 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "shrink")) flags |= VIR_STORAGE_VOL_RESIZE_SHRINK; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; @@ -981,9 +951,6 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd) bool ret = true; char *dump; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; @@ -1039,10 +1006,6 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) }; 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 */ if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL))) return false; @@ -1315,9 +1278,6 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd) { virStorageVolPtr vol; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, VSH_BYUUID))) return false; @@ -1349,10 +1309,6 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr vol; 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 */ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, VSH_BYUUID))) { @@ -1403,9 +1359,6 @@ cmdVolKey(vshControl *ctl, const vshCmd *cmd) { virStorageVolPtr vol; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; @@ -1435,9 +1388,6 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr vol; char * StorageVolPath; - if (!vshConnectionUsability(ctl, ctl->conn)) - return false; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) { return false; } diff --git a/tools/virsh.c b/tools/virsh.c index f144616b2..5cf3237dd 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1465,6 +1465,23 @@ vshCmdHasOption(vshControl *ctl, const vshCmd *cmd, const char *optname) 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 */ @@ -1951,23 +1968,6 @@ vshFindTypedParamByName(const char *name, virTypedParameterPtr list, int count) 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 vshDebug(vshControl *ctl, int level, const char *format, ...) { diff --git a/tools/virsh.h b/tools/virsh.h index 698899d0d..8923f946b 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -315,7 +315,6 @@ void vshDebug(vshControl *ctl, int level, const char *format, ...) int vshNameSorter(const void *a, const void *b); int vshDomainState(vshControl *ctl, virDomainPtr dom, int *reason); -bool vshConnectionUsability(vshControl *ctl, virConnectPtr conn); virTypedParameterPtr vshFindTypedParamByName(const char *name, virTypedParameterPtr list, int count); |