On Fri, Jul 17, 2015 at 02:34:20PM +0200, Erik Skultety wrote:
V1 introduced quite a big refactor, so to be able to better keep track of changes performed from v1 to v2, only this v2 diff patch is presented and eventually will be squashed to the previous series with a different commit message. --- You can still checkout the forked repo https://github.com/eskultety/libvirt/tree/virt-shell cfg.mk | 2 +- tools/virsh-domain-monitor.c | 3 +- tools/virsh-domain.c | 668 ++++++++++++++++++++++--------------------- tools/virsh-domain.h | 3 +- tools/virsh-edit.c | 8 +- tools/virsh-interface.c | 42 +-- tools/virsh-interface.h | 2 +- tools/virsh-network.c | 76 ++--- tools/virsh-network.h | 2 +- tools/virsh-nodedev.c | 38 +-- tools/virsh-nwfilter.c | 34 +-- tools/virsh-nwfilter.h | 2 +- tools/virsh-pool.c | 66 ++--- tools/virsh-pool.h | 2 +- tools/virsh-secret.c | 28 +- tools/virsh-snapshot.c | 94 +++--- tools/virsh-volume.c | 52 ++-- tools/virsh-volume.h | 2 +- tools/virsh.c | 339 +--------------------- tools/virsh.h | 25 +- tools/vsh.c | 559 ++++++++++++++++++++++++++++++------ tools/vsh.h | 32 ++- 22 files changed, 1062 insertions(+), 1017 deletions(-) diff --git a/cfg.mk b/cfg.mk index f26191f..e436434 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1086,7 +1086,7 @@ $(srcdir)/src/admin/admin_client.h: $(srcdir)/src/admin/admin_protocol.x $(MAKE) -C src admin/admin_client.h # List all syntax-check exemptions: -exclude_file_name_regexp--sc_avoid_strcase = ^tools/(virsh|vsh)\.h$$ +exclude_file_name_regexp--sc_avoid_strcase = ^tools/vsh\.h$$ _src1=libvirt-stream|fdstream|qemu/qemu_monitor|util/(vircommand|virfile)|xen/xend_internal|rpc/virnetsocket|lxc/lxc_controller|locking/lock_daemon _test1=shunloadtest|virnettlscontexttest|virnettlssessiontest|vircgroupmock diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 0762d6e..340a8e2 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2165,7 +2165,8 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) while ((opt = vshCommandOptArgv(ctl, cmd, opt))) { if (!(dom = virshLookupDomainBy(ctl, opt->data, - VSH_BYID | VSH_BYUUID | VSH_BYNAME))) + VIRSH_BYID | + VIRSH_BYUUID | VIRSH_BYNAME))) goto cleanup; if (VIR_INSERT_ELEMENT(domlist, ndoms - 1, ndoms, dom) < 0) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index df423c7..ff026fb 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -70,11 +70,11 @@ virshLookupDomainInternal(vshControl *ctl, { virDomainPtr dom = NULL; int id; - virCheckFlags(VSH_BYID | VSH_BYUUID | VSH_BYNAME, NULL); + virCheckFlags(VIRSH_BYID | VIRSH_BYUUID | VIRSH_BYNAME, NULL); virshControlPtr priv = ctl->privData; /* try it by ID */ - if (flags & VSH_BYID) { + if (flags & VIRSH_BYID) { if (virStrToLong_i(name, NULL, 10, &id) == 0 && id >= 0) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <domain> looks like ID\n", cmdname); @@ -83,7 +83,7 @@ virshLookupDomainInternal(vshControl *ctl, } /* try it by UUID */ - if (!dom && (flags & VSH_BYUUID) && + if (!dom && (flags & VIRSH_BYUUID) && strlen(name) == VIR_UUID_STRING_BUFLEN-1) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <domain> trying as domain UUID\n", cmdname); @@ -91,7 +91,7 @@ virshLookupDomainInternal(vshControl *ctl, } /* try it by NAME */ - if (!dom && (flags & VSH_BYNAME)) { + if (!dom && (flags & VIRSH_BYNAME)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <domain> trying as domain NAME\n", cmdname); dom = virDomainLookupByName(priv->conn, name); @@ -106,8 +106,8 @@ virshLookupDomainInternal(vshControl *ctl, virDomainPtr virshLookupDomainBy(vshControl *ctl, - const char *name, - unsigned int flags) + const char *name, + unsigned int flags) { return virshLookupDomainInternal(ctl, "unknown", name, flags); } @@ -265,7 +265,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) virDomainIsActive(dom) == 1) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) { + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); goto cleanup; } @@ -902,8 +902,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom = NULL; const char *mac = NULL, *target = NULL, *script = NULL, - *type = NULL, *source = NULL, *model = NULL, - *inboundStr = NULL, *outboundStr = NULL; + *type = NULL, *source = NULL, *model = NULL, + *inboundStr = NULL, *outboundStr = NULL; virNetDevBandwidthRate inbound, outbound; virDomainNetType typ; int ret; @@ -1780,9 +1780,9 @@ virshPrintJobProgress(const char *label, unsigned long long remaining, static volatile sig_atomic_t intCaught; -static void vshCatchInt(int sig ATTRIBUTE_UNUSED, - siginfo_t *siginfo ATTRIBUTE_UNUSED, - void *context ATTRIBUTE_UNUSED) +static void virshCatchInt(int sig ATTRIBUTE_UNUSED, + siginfo_t *siginfo ATTRIBUTE_UNUSED, + void *context ATTRIBUTE_UNUSED) { intCaught = 1; } @@ -1918,7 +1918,7 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd) sigaddset(&sigmask, SIGINT); intCaught = 0; - sig_action.sa_sigaction = vshCatchInt; + sig_action.sa_sigaction = virshCatchInt; sig_action.sa_flags = SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); @@ -2183,7 +2183,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd) sigaddset(&sigmask, SIGINT); intCaught = 0; - sig_action.sa_sigaction = vshCatchInt; + sig_action.sa_sigaction = virshCatchInt; sig_action.sa_flags = SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); @@ -2220,7 +2220,7 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd) goto cleanup; if (xml) { - if (virFileReadAll(xml, VIRSH_MAX_XML_FILE, &xmlstr) < 0) { + if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlstr) < 0) { vshReportError(ctl); goto cleanup; } @@ -2438,8 +2438,8 @@ static const vshCmdOptDef opts_block_job[] = { {.name = NULL} }; -VIR_ENUM_DECL(vshDomainBlockJob) -VIR_ENUM_IMPL(vshDomainBlockJob, +VIR_ENUM_DECL(virshDomainBlockJob) +VIR_ENUM_IMPL(virshDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST, N_("Unknown job"), N_("Block Pull"), @@ -2448,9 +2448,9 @@ VIR_ENUM_IMPL(vshDomainBlockJob, N_("Active Block Commit")) static const char * -vshDomainBlockJobToString(int type) +virshDomainBlockJobToString(int type) { - const char *str = vshDomainBlockJobTypeToString(type); + const char *str = virshDomainBlockJobTypeToString(type); return str ? _(str) : _("Unknown job"); } @@ -2547,14 +2547,14 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd) if (raw) { vshPrint(ctl, _(" type=%s\n bandwidth=%lu\n cur=%llu\n end=%llu\n"), - vshDomainBlockJobTypeToString(info.type), + virshDomainBlockJobTypeToString(info.type), info.bandwidth, info.cur, info.end); } else { - virshPrintJobProgress(vshDomainBlockJobToString(info.type), + virshPrintJobProgress(virshDomainBlockJobToString(info.type), info.end - info.cur, info.end); if (speed) { const char *unit; - double val = virshPrettyCapacity(speed, &unit); + double val = vshPrettyCapacity(speed, &unit); vshPrint(ctl, _(" Bandwidth limit: %llu bytes/s (%-.3lf %s/s)"), speed, val, unit); } @@ -2654,7 +2654,7 @@ cmdBlockPull(vshControl *ctl, const vshCmd *cmd) sigaddset(&sigmask, SIGINT); intCaught = 0; - sig_action.sa_sigaction = vshCatchInt; + sig_action.sa_sigaction = virshCatchInt; sig_action.sa_flags = SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); @@ -3527,7 +3527,7 @@ typedef struct { virStorageVolPtr vol; char *source; char *target; -} vshUndefineVolume; +} virshUndefineVolume; static bool cmdUndefine(vshControl *ctl, const vshCmd *cmd) @@ -3556,7 +3556,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) const char *vol_string = NULL; /* string containing volumes to delete */ char **vol_list = NULL; /* tokenized vol_string */ int nvol_list = 0; - vshUndefineVolume *vols = NULL; /* info about the volumes to delete*/ + virshUndefineVolume *vols = NULL; /* info about the volumes to delete*/ size_t nvols = 0; char *def = NULL; /* domain def */ xmlDocPtr doc = NULL; @@ -3680,7 +3680,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) for (i = 0; i < nvol_nodes; i++) { ctxt->node = vol_nodes[i]; - vshUndefineVolume vol; + virshUndefineVolume vol; VIR_FREE(source); VIR_FREE(target); VIR_FREE(pool); @@ -3996,7 +3996,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) int *fds = NULL; if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL, - VSH_BYNAME | VSH_BYUUID))) + VIRSH_BYNAME | VIRSH_BYUUID))) return false; if (virDomainGetID(dom) != (unsigned int)-1) { @@ -4149,7 +4149,7 @@ doSave(void *opaque) goto out; if (xmlfile && - virFileReadAll(xmlfile, VIRSH_MAX_XML_FILE, &xml) < 0) { + virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) { vshReportError(ctl); goto out; } @@ -4176,14 +4176,14 @@ typedef void (*jobWatchTimeoutFunc)(vshControl *ctl, virDomainPtr dom, void *opaque); static bool -vshWatchJob(vshControl *ctl, - virDomainPtr dom, - bool verbose, - int pipe_fd, - int timeout_ms, - jobWatchTimeoutFunc timeout_func, - void *opaque, - const char *label) +virshWatchJob(vshControl *ctl, + virDomainPtr dom, + bool verbose, + int pipe_fd, + int timeout_ms, + jobWatchTimeoutFunc timeout_func, + void *opaque, + const char *label) { struct sigaction sig_action; struct sigaction old_sig_action; @@ -4202,7 +4202,7 @@ vshWatchJob(vshControl *ctl, sigaddset(&sigmask, SIGINT); intCaught = 0; - sig_action.sa_sigaction = vshCatchInt; + sig_action.sa_sigaction = virshCatchInt; sig_action.sa_flags = SA_SIGINFO; sigemptyset(&sig_action.sa_mask); sigaction(SIGINT, &sig_action, &old_sig_action); @@ -4319,7 +4319,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) &data) < 0) goto cleanup; - ret = vshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Save")); + ret = virshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Save")); virThreadJoin(&workerThread); @@ -4440,7 +4440,7 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) return false; - if (virFileReadAll(xmlfile, VIRSH_MAX_XML_FILE, &xml) < 0) + if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) goto cleanup; if (virDomainSaveImageDefineXML(priv->conn, file, xml, flags) < 0) { @@ -4644,8 +4644,8 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd) &data) < 0) goto cleanup; - ret = vshWatchJob(ctl, dom, verbose, p[0], 0, - NULL, NULL, _("Managedsave")); + ret = virshWatchJob(ctl, dom, verbose, p[0], 0, + NULL, NULL, _("Managedsave")); virThreadJoin(&workerThread); @@ -5028,7 +5028,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) return false; if (xmlfile && - virFileReadAll(xmlfile, VIRSH_MAX_XML_FILE, &xml) < 0) + virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) goto cleanup; if (((flags || xml) @@ -5217,7 +5217,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) &data) < 0) goto cleanup; - ret = vshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Dump")); + ret = virshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Dump")); virThreadJoin(&workerThread); @@ -5729,8 +5729,8 @@ static const vshCmdOptDef opts_domjobinfo[] = { {.name = NULL} }; -VIR_ENUM_DECL(vshDomainJob) -VIR_ENUM_IMPL(vshDomainJob, +VIR_ENUM_DECL(virshDomainJob) +VIR_ENUM_IMPL(virshDomainJob, VIR_DOMAIN_JOB_LAST, N_("None"), N_("Bounded"), @@ -5740,9 +5740,9 @@ VIR_ENUM_IMPL(vshDomainJob, N_("Cancelled")) static const char * -vshDomainJobToString(int type) +virshDomainJobToString(int type) { - const char *str = vshDomainJobTypeToString(type); + const char *str = virshDomainJobTypeToString(type); return str ? _(str) : _("unknown"); } @@ -5818,7 +5818,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) goto cleanup; vshPrint(ctl, "%-17s %-12s\n", _("Job type:"), - vshDomainJobToString(info.type)); + virshDomainJobToString(info.type)); if (info.type != VIR_DOMAIN_JOB_BOUNDED && info.type != VIR_DOMAIN_JOB_UNBOUNDED && (!(flags & VIR_DOMAIN_JOB_STATS_COMPLETED) || @@ -5842,20 +5842,20 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) info.timeRemaining); if (info.dataTotal || info.dataRemaining || info.dataProcessed) { - val = virshPrettyCapacity(info.dataProcessed, &unit); + val = vshPrettyCapacity(info.dataProcessed, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data processed:"), val, unit); - val = virshPrettyCapacity(info.dataRemaining, &unit); + val = vshPrettyCapacity(info.dataRemaining, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data remaining:"), val, unit); - val = virshPrettyCapacity(info.dataTotal, &unit); + val = vshPrettyCapacity(info.dataTotal, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Data total:"), val, unit); } if (info.memTotal || info.memRemaining || info.memProcessed) { - val = virshPrettyCapacity(info.memProcessed, &unit); + val = vshPrettyCapacity(info.memProcessed, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory processed:"), val, unit); - val = virshPrettyCapacity(info.memRemaining, &unit); + val = vshPrettyCapacity(info.memRemaining, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory remaining:"), val, unit); - val = virshPrettyCapacity(info.memTotal, &unit); + val = vshPrettyCapacity(info.memTotal, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Memory total:"), val, unit); if ((rc = virTypedParamsGetULLong(params, nparams, @@ -5863,18 +5863,18 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) &value)) < 0) { goto save_error; } else if (rc && value) { - val = virshPrettyCapacity(value, &unit); + val = vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s/s\n", _("Memory bandwidth:"), val, unit); } } if (info.fileTotal || info.fileRemaining || info.fileProcessed) { - val = virshPrettyCapacity(info.fileProcessed, &unit); + val = vshPrettyCapacity(info.fileProcessed, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("File processed:"), val, unit); - val = virshPrettyCapacity(info.fileRemaining, &unit); + val = vshPrettyCapacity(info.fileRemaining, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("File remaining:"), val, unit); - val = virshPrettyCapacity(info.fileTotal, &unit); + val = vshPrettyCapacity(info.fileTotal, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("File total:"), val, unit); if ((rc = virTypedParamsGetULLong(params, nparams, @@ -5882,7 +5882,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) &value)) < 0) { goto save_error; } else if (rc && value) { - val = virshPrettyCapacity(value, &unit); + val = vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s/s\n", _("File bandwidth:"), val, unit); } @@ -5907,7 +5907,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) &value)) < 0) { goto save_error; } else if (rc) { - val = virshPrettyCapacity(value, &unit); + val = vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Normal data:"), val, unit); } @@ -5944,7 +5944,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) &value)) < 0) { goto save_error; } else if (rc) { - val = virshPrettyCapacity(value, &unit); + val = vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Compression cache:"), val, unit); } if ((rc = virTypedParamsGetULLong(params, nparams, @@ -5952,7 +5952,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) &value)) < 0) { goto save_error; } else if (rc) { - val = virshPrettyCapacity(value, &unit); + val = vshPrettyCapacity(value, &unit); vshPrint(ctl, "%-17s %-.3lf %s\n", _("Compressed data:"), val, unit); } if ((rc = virTypedParamsGetULLong(params, nparams, @@ -6083,10 +6083,10 @@ static const vshCmdOptDef opts_vcpucount[] = { */ static int -vshCPUCountCollect(vshControl *ctl, - virDomainPtr dom, - unsigned int flags, - bool checkState) +virshCPUCountCollect(vshControl *ctl, + virDomainPtr dom, + unsigned int flags, + bool checkState) { int ret = -2; virDomainInfo info; @@ -6204,12 +6204,16 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) return false; if (all) { - int conf_max = vshCPUCountCollect(ctl, dom, VIR_DOMAIN_AFFECT_CONFIG | - VIR_DOMAIN_VCPU_MAXIMUM, true); - int conf_cur = vshCPUCountCollect(ctl, dom, VIR_DOMAIN_AFFECT_CONFIG, true); - int live_max = vshCPUCountCollect(ctl, dom, VIR_DOMAIN_AFFECT_LIVE | - VIR_DOMAIN_VCPU_MAXIMUM, true); - int live_cur = vshCPUCountCollect(ctl, dom, VIR_DOMAIN_AFFECT_LIVE, true); + int conf_max = virshCPUCountCollect(ctl, dom, + VIR_DOMAIN_AFFECT_CONFIG | + VIR_DOMAIN_VCPU_MAXIMUM, true); + int conf_cur = virshCPUCountCollect(ctl, dom, + VIR_DOMAIN_AFFECT_CONFIG, true); + int live_max = virshCPUCountCollect(ctl, dom, + VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_VCPU_MAXIMUM, true); + int live_cur = virshCPUCountCollect(ctl, dom, + VIR_DOMAIN_AFFECT_LIVE, true); if (conf_max == -2 || conf_cur == -2 || live_max == -2 || live_cur == -2) goto cleanup; @@ -6223,7 +6227,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) #undef PRINT_COUNT } else { - int count = vshCPUCountCollect(ctl, dom, flags, false); + int count = virshCPUCountCollect(ctl, dom, flags, false); if (count < 0) goto cleanup; @@ -6400,7 +6404,7 @@ static const vshCmdOptDef opts_vcpupin[] = { * Helper function to print vcpupin info. */ static bool -vshPrintPinInfo(unsigned char *cpumap, size_t cpumaplen) +virshPrintPinInfo(unsigned char *cpumap, size_t cpumaplen) { char *str = NULL; @@ -6413,7 +6417,8 @@ vshPrintPinInfo(unsigned char *cpumap, size_t cpumaplen) } static unsigned char * -vshParseCPUList(vshControl *ctl, int *cpumaplen, const char *cpulist, int maxcpu) +virshParseCPUList(vshControl *ctl, int *cpumaplen, + const char *cpulist, int maxcpu) { unsigned char *cpumap = NULL; virBitmapPtr map = NULL; @@ -6501,7 +6506,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) if (flags == -1) flags = VIR_DOMAIN_AFFECT_CURRENT; - if ((ncpus = vshCPUCountCollect(ctl, dom, flags, true)) < 0) { + if ((ncpus = virshCPUCountCollect(ctl, dom, flags, true)) < 0) { if (ncpus == -1) { if (flags & VIR_DOMAIN_AFFECT_LIVE) vshError(ctl, "%s", _("cannot get vcpupin for offline domain")); @@ -6536,8 +6541,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) continue; vshPrint(ctl, "%4zu: ", i); - ret = vshPrintPinInfo(VIR_GET_CPUMAP(cpumap, cpumaplen, i), - cpumaplen); + ret = virshPrintPinInfo(VIR_GET_CPUMAP(cpumap, cpumaplen, i), + cpumaplen); vshPrint(ctl, "\n"); if (!ret) break; @@ -6545,7 +6550,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) } } else { /* Pin mode: pinning specified vcpu to specified physical cpus*/ - if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) + if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) goto cleanup; if (flags == -1) { @@ -6658,14 +6663,14 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, "%s %s\n", _("emulator:"), _("CPU Affinity")); vshPrintExtra(ctl, "----------------------------------\n"); vshPrintExtra(ctl, " *: "); - ret = vshPrintPinInfo(cpumap, cpumaplen); + ret = virshPrintPinInfo(cpumap, cpumaplen); vshPrint(ctl, "\n"); } goto cleanup; } /* Pin mode: pinning emulator threads to specified physical cpus*/ - if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) + if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) goto cleanup; if (flags == -1) @@ -6855,7 +6860,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) for (i = 0; i < niothreads; i++) { vshPrint(ctl, " %-15u ", info[i]->iothread_id); - ignore_value(vshPrintPinInfo(info[i]->cpumap, info[i]->cpumaplen)); + ignore_value(virshPrintPinInfo(info[i]->cpumap, info[i]->cpumaplen)); vshPrint(ctl, "\n"); virDomainIOThreadInfoFree(info[i]); } @@ -6948,7 +6953,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) if ((maxcpu = virshNodeGetCPUCount(priv->conn)) < 0) goto cleanup; - if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) + if (!(cpumap = virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) goto cleanup; if (virDomainPinIOThread(dom, iothread_id, @@ -7165,7 +7170,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; /* try to extract the CPU element from as it would appear in a domain XML*/ @@ -7277,7 +7282,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; /* add a separate container around the xml */ @@ -7589,7 +7594,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0) @@ -7669,7 +7674,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "validate")) flags |= VIR_DOMAIN_DEFINE_VALIDATE; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; if (flags) @@ -7857,15 +7862,15 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) if (edit) { /* Create and open the temporary file. */ - if (!(tmp = virshEditWriteToTempFile(ctl, desc))) + if (!(tmp = vshEditWriteToTempFile(ctl, desc))) goto cleanup; /* Start the editor. */ - if (virshEditFile(ctl, tmp) == -1) + if (vshEditFile(ctl, tmp) == -1) goto cleanup; /* Read back the edited file. */ - if (!(desc_edited = virshEditReadBackFile(ctl, tmp))) + if (!(desc_edited = vshEditReadBackFile(ctl, tmp))) goto cleanup; /* strip a possible newline at the end of file; some @@ -7983,10 +7988,10 @@ static const vshCmdOptDef opts_metadata[] = { /* helper to add new metadata using the --edit option */ static char * -vshDomainGetEditMetadata(vshControl *ctl, - virDomainPtr dom, - const char *uri, - unsigned int flags) +virshDomainGetEditMetadata(vshControl *ctl, + virDomainPtr dom, + const char *uri, + unsigned int flags) { char *ret; @@ -8051,7 +8056,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) vshPrint("%s\n", _("Metadata modified")); } else if (edit) { #define EDIT_GET_XML \ - vshDomainGetEditMetadata(ctl, dom, uri, flags) + virshDomainGetEditMetadata(ctl, dom, uri, flags) #define EDIT_NOT_CHANGED \ do { \ vshPrint(ctl, "%s", _("Metadata not changed")); \ @@ -8160,7 +8165,7 @@ static const vshCmdOptDef opts_send_key[] = { }; static int -vshKeyCodeGetInt(const char *key_name) +virshKeyCodeGetInt(const char *key_name) { unsigned int val; @@ -8203,7 +8208,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if ((keycode = vshKeyCodeGetInt(opt->data)) < 0) { + if ((keycode = virshKeyCodeGetInt(opt->data)) < 0) { if ((keycode = virKeycodeValueFromString(codeset, opt->data)) < 0) { vshError(ctl, _("invalid keycode: '%s'"), opt->data); goto cleanup; @@ -8577,7 +8582,7 @@ static const vshCmdOptDef opts_memtune[] = { }; /** - * vshMemtuneGetSize + * virshMemtuneGetSize * * @cmd: pointer to vshCmd * @name: name of a parameter for which we would like to get a value @@ -8593,7 +8598,8 @@ static const vshCmdOptDef opts_memtune[] = { * <0 in all other cases */ static int -vshMemtuneGetSize(vshControl *ctl, const vshCmd *cmd, const char *name, long long *value) +virshMemtuneGetSize(vshControl *ctl, const vshCmd *cmd, + const char *name, long long *value) { int ret; unsigned long long tmp; @@ -8644,7 +8650,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd) return false; #define PARSE_MEMTUNE_PARAM(NAME, FIELD) \ - if ((rc = vshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) { \ + if ((rc = virshMemtuneGetSize(ctl, cmd, NAME, &tmpVal)) < 0) { \ vshError(ctl, _("Unable to parse integer parameter %s"), NAME); \ goto cleanup; \ } \ @@ -8975,9 +8981,9 @@ struct virshQemuEventData { typedef struct virshQemuEventData virshQemuEventData; static void -vshEventPrint(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, - const char *event, long long seconds, unsigned int micros, - const char *details, void *opaque) +virshEventPrint(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, + const char *event, long long seconds, unsigned int micros, + const char *details, void *opaque) { virshQemuEventData *data = opaque; virJSONValuePtr pretty = NULL; @@ -9074,7 +9080,7 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd) if ((eventId = virConnectDomainQemuMonitorEventRegister(priv->conn, dom, event, - vshEventPrint, + virshEventPrint, &data, NULL, flags)) < 0) goto cleanup; @@ -9539,7 +9545,7 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "config", &configFile) < 0) return false; - if (virFileReadAll(configFile, VIRSH_MAX_XML_FILE, &configData) < 0) + if (virFileReadAll(configFile, VSH_MAX_XML_FILE, &configData) < 0) return false; xmlData = virConnectDomainXMLFromNative(priv->conn, format, configData, flags); @@ -9596,7 +9602,7 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0) return false; - if (virFileReadAll(xmlFile, VIRSH_MAX_XML_FILE, &xmlData) < 0) + if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0) return false; configData = virConnectDomainXMLToNative(priv->conn, format, xmlData, flags); @@ -9639,7 +9645,7 @@ cmdDomname(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom; if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL, - VSH_BYID|VSH_BYUUID))) + VIRSH_BYID|VIRSH_BYUUID))) return false; vshPrint(ctl, "%s\n", virDomainGetName(dom)); @@ -9676,7 +9682,7 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd) unsigned int id; if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL, - VSH_BYNAME|VSH_BYUUID))) + VIRSH_BYNAME|VIRSH_BYUUID))) return false; id = virDomainGetID(dom); @@ -9717,7 +9723,7 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd) char uuid[VIR_UUID_STRING_BUFLEN]; if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL, - VSH_BYNAME|VSH_BYID))) + VIRSH_BYNAME|VIRSH_BYID))) return false; if (virDomainGetUUIDString(dom, uuid) != -1) @@ -9936,7 +9942,7 @@ doMigrate(void *opaque) if (opt) { char *xml; - if (virFileReadAll(opt, VIRSH_MAX_XML_FILE, &xml) < 0) { + if (virFileReadAll(opt, VSH_MAX_XML_FILE, &xml) < 0) { vshError(ctl, _("cannot read file '%s'"), opt); goto save_error; } @@ -10019,9 +10025,9 @@ doMigrate(void *opaque) } static void -vshMigrationTimeout(vshControl *ctl, - virDomainPtr dom, - void *opaque ATTRIBUTE_UNUSED) +virshMigrationTimeout(vshControl *ctl, + virDomainPtr dom, + void *opaque ATTRIBUTE_UNUSED) { vshDebug(ctl, VSH_ERR_DEBUG, "suspending the domain, " "since migration timed out\n"); @@ -10085,8 +10091,8 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) doMigrate, &data) < 0) goto cleanup; - functionReturn = vshWatchJob(ctl, dom, verbose, p[0], timeout, - vshMigrationTimeout, NULL, _("Migration")); + functionReturn = virshWatchJob(ctl, dom, verbose, p[0], timeout, + virshMigrationTimeout, NULL, _("Migration")); virThreadJoin(&workerThread); @@ -10205,7 +10211,7 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd) if (virDomainMigrateGetCompressionCache(dom, &size, 0) < 0) goto cleanup; - value = virshPrettyCapacity(size, &unit); + value = vshPrettyCapacity(size, &unit); vshPrint(ctl, _("Compression cache: %.3lf %s"), value, unit); ret = true; @@ -10734,7 +10740,7 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd) */ ATTRIBUTE_UNUSED static bool -vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) +virshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) { xmlNodePtr child1, child2; xmlAttrPtr attr; @@ -10817,7 +10823,7 @@ vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) goto cleanup; } - if (!vshNodeIsSuperset(child1, child2)) + if (!virshNodeIsSuperset(child1, child2)) goto cleanup; break; @@ -10918,7 +10924,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) goto cleanup; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) { + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); goto cleanup; } @@ -11022,7 +11028,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) virDomainIsActive(dom) == 1) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) { + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); goto cleanup; } @@ -11228,7 +11234,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) typedef enum { VIRSH_FIND_DISK_NORMAL, VIRSH_FIND_DISK_CHANGEABLE, -} vshFindDiskType; +} virshFindDiskType; /* Helper function to find disk device in XML doc. Returns the disk * node on success, or NULL on failure. Caller must free the result @@ -11236,9 +11242,9 @@ typedef enum { * @type: Either VIRSH_FIND_DISK_NORMAL or VIRSH_FIND_DISK_CHANGEABLE. */ static xmlNodePtr -vshFindDisk(const char *doc, - const char *path, - int type) +virshFindDisk(const char *doc, + const char *path, + int type) { xmlDocPtr xml = NULL; xmlXPathObjectPtr obj = NULL; @@ -11324,7 +11330,7 @@ typedef enum { VIRSH_UPDATE_DISK_XML_EJECT, VIRSH_UPDATE_DISK_XML_INSERT, VIRSH_UPDATE_DISK_XML_UPDATE, -} vshUpdateDiskXMLType; +} virshUpdateDiskXMLType; /* Helper function to prepare disk XML. Could be used for disk * detaching, media changing(ejecting, inserting, updating) @@ -11332,11 +11338,11 @@ typedef enum { * success, or NULL on failure. Caller must free the result. */ static char * -vshUpdateDiskXML(xmlNodePtr disk_node, - const char *new_source, - bool source_block, - const char *target, - vshUpdateDiskXMLType type) +virshUpdateDiskXML(xmlNodePtr disk_node, + const char *new_source, + bool source_block, + const char *target, + virshUpdateDiskXMLType type) { xmlNodePtr source = NULL; char *device_type = NULL; @@ -11505,7 +11511,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) virDomainIsActive(dom) == 1) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (!(disk_node = vshFindDisk(doc, target, VIRSH_FIND_DISK_NORMAL))) + if (!(disk_node = virshFindDisk(doc, target, VIRSH_FIND_DISK_NORMAL))) goto cleanup; if (!(disk_xml = virXMLNodeToString(NULL, disk_node))) { @@ -11613,8 +11619,8 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd) /* * "event" command */ -VIR_ENUM_DECL(vshDomainEvent) -VIR_ENUM_IMPL(vshDomainEvent, +VIR_ENUM_DECL(virshDomainEvent) +VIR_ENUM_IMPL(virshDomainEvent, VIR_DOMAIN_EVENT_LAST, N_("Defined"), N_("Undefined"), @@ -11627,25 +11633,25 @@ VIR_ENUM_IMPL(vshDomainEvent, N_("Crashed")) static const char * -vshDomainEventToString(int event) +virshDomainEventToString(int event) { - const char *str = vshDomainEventTypeToString(event); + const char *str = virshDomainEventTypeToString(event); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshDomainEventDefined) -VIR_ENUM_IMPL(vshDomainEventDefined, +VIR_ENUM_DECL(virshDomainEventDefined) +VIR_ENUM_IMPL(virshDomainEventDefined, VIR_DOMAIN_EVENT_DEFINED_LAST, N_("Added"), N_("Updated")) -VIR_ENUM_DECL(vshDomainEventUndefined) -VIR_ENUM_IMPL(vshDomainEventUndefined, +VIR_ENUM_DECL(virshDomainEventUndefined) +VIR_ENUM_IMPL(virshDomainEventUndefined, VIR_DOMAIN_EVENT_UNDEFINED_LAST, N_("Removed")) -VIR_ENUM_DECL(vshDomainEventStarted) -VIR_ENUM_IMPL(vshDomainEventStarted, +VIR_ENUM_DECL(virshDomainEventStarted) +VIR_ENUM_IMPL(virshDomainEventStarted, VIR_DOMAIN_EVENT_STARTED_LAST, N_("Booted"), N_("Migrated"), @@ -11653,8 +11659,8 @@ VIR_ENUM_IMPL(vshDomainEventStarted, N_("Snapshot"), N_("Event wakeup")) -VIR_ENUM_DECL(vshDomainEventSuspended) -VIR_ENUM_IMPL(vshDomainEventSuspended, +VIR_ENUM_DECL(virshDomainEventSuspended) +VIR_ENUM_IMPL(virshDomainEventSuspended, VIR_DOMAIN_EVENT_SUSPENDED_LAST, N_("Paused"), N_("Migrated"), @@ -11664,15 +11670,15 @@ VIR_ENUM_IMPL(vshDomainEventSuspended, N_("Snapshot"), N_("API error")) -VIR_ENUM_DECL(vshDomainEventResumed) -VIR_ENUM_IMPL(vshDomainEventResumed, +VIR_ENUM_DECL(virshDomainEventResumed) +VIR_ENUM_IMPL(virshDomainEventResumed, VIR_DOMAIN_EVENT_RESUMED_LAST, N_("Unpaused"), N_("Migrated"), N_("Snapshot")) -VIR_ENUM_DECL(vshDomainEventStopped) -VIR_ENUM_IMPL(vshDomainEventStopped, +VIR_ENUM_DECL(virshDomainEventStopped) +VIR_ENUM_IMPL(virshDomainEventStopped, VIR_DOMAIN_EVENT_STOPPED_LAST, N_("Shutdown"), N_("Destroyed"), @@ -11682,53 +11688,53 @@ VIR_ENUM_IMPL(vshDomainEventStopped, N_("Failed"), N_("Snapshot")) -VIR_ENUM_DECL(vshDomainEventShutdown) -VIR_ENUM_IMPL(vshDomainEventShutdown, +VIR_ENUM_DECL(virshDomainEventShutdown) +VIR_ENUM_IMPL(virshDomainEventShutdown, VIR_DOMAIN_EVENT_SHUTDOWN_LAST, N_("Finished")) -VIR_ENUM_DECL(vshDomainEventPMSuspended) -VIR_ENUM_IMPL(vshDomainEventPMSuspended, +VIR_ENUM_DECL(virshDomainEventPMSuspended) +VIR_ENUM_IMPL(virshDomainEventPMSuspended, VIR_DOMAIN_EVENT_PMSUSPENDED_LAST, N_("Memory"), N_("Disk")) -VIR_ENUM_DECL(vshDomainEventCrashed) -VIR_ENUM_IMPL(vshDomainEventCrashed, +VIR_ENUM_DECL(virshDomainEventCrashed) +VIR_ENUM_IMPL(virshDomainEventCrashed, VIR_DOMAIN_EVENT_CRASHED_LAST, N_("Panicked")) static const char * -vshDomainEventDetailToString(int event, int detail) +virshDomainEventDetailToString(int event, int detail) { const char *str = NULL; switch ((virDomainEventType) event) { case VIR_DOMAIN_EVENT_DEFINED: - str = vshDomainEventDefinedTypeToString(detail); + str = virshDomainEventDefinedTypeToString(detail); break; case VIR_DOMAIN_EVENT_UNDEFINED: - str = vshDomainEventUndefinedTypeToString(detail); + str = virshDomainEventUndefinedTypeToString(detail); break; case VIR_DOMAIN_EVENT_STARTED: - str = vshDomainEventStartedTypeToString(detail); + str = virshDomainEventStartedTypeToString(detail); break; case VIR_DOMAIN_EVENT_SUSPENDED: - str = vshDomainEventSuspendedTypeToString(detail); + str = virshDomainEventSuspendedTypeToString(detail); break; case VIR_DOMAIN_EVENT_RESUMED: - str = vshDomainEventResumedTypeToString(detail); + str = virshDomainEventResumedTypeToString(detail); break; case VIR_DOMAIN_EVENT_STOPPED: - str = vshDomainEventStoppedTypeToString(detail); + str = virshDomainEventStoppedTypeToString(detail); break; case VIR_DOMAIN_EVENT_SHUTDOWN: - str = vshDomainEventShutdownTypeToString(detail); + str = virshDomainEventShutdownTypeToString(detail); break; case VIR_DOMAIN_EVENT_PMSUSPENDED: - str = vshDomainEventPMSuspendedTypeToString(detail); + str = virshDomainEventPMSuspendedTypeToString(detail); break; case VIR_DOMAIN_EVENT_CRASHED: - str = vshDomainEventCrashedTypeToString(detail); + str = virshDomainEventCrashedTypeToString(detail); break; case VIR_DOMAIN_EVENT_LAST: break; @@ -11736,8 +11742,8 @@ vshDomainEventDetailToString(int event, int detail) return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshDomainEventWatchdog) -VIR_ENUM_IMPL(vshDomainEventWatchdog, +VIR_ENUM_DECL(virshDomainEventWatchdog) +VIR_ENUM_IMPL(virshDomainEventWatchdog, VIR_DOMAIN_EVENT_WATCHDOG_LAST, N_("none"), N_("pause"), @@ -11748,56 +11754,56 @@ VIR_ENUM_IMPL(vshDomainEventWatchdog, N_("inject-nmi")) static const char * -vshDomainEventWatchdogToString(int action) +virshDomainEventWatchdogToString(int action) { - const char *str = vshDomainEventWatchdogTypeToString(action); + const char *str = virshDomainEventWatchdogTypeToString(action); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshDomainEventIOError) -VIR_ENUM_IMPL(vshDomainEventIOError, +VIR_ENUM_DECL(virshDomainEventIOError) +VIR_ENUM_IMPL(virshDomainEventIOError, VIR_DOMAIN_EVENT_IO_ERROR_LAST, N_("none"), N_("pause"), N_("report")) static const char * -vshDomainEventIOErrorToString(int action) +virshDomainEventIOErrorToString(int action) { - const char *str = vshDomainEventIOErrorTypeToString(action); + const char *str = virshDomainEventIOErrorTypeToString(action); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshGraphicsPhase) -VIR_ENUM_IMPL(vshGraphicsPhase, +VIR_ENUM_DECL(virshGraphicsPhase) +VIR_ENUM_IMPL(virshGraphicsPhase, VIR_DOMAIN_EVENT_GRAPHICS_LAST, N_("connect"), N_("initialize"), N_("disconnect")) static const char * -vshGraphicsPhaseToString(int phase) +virshGraphicsPhaseToString(int phase) { - const char *str = vshGraphicsPhaseTypeToString(phase); + const char *str = virshGraphicsPhaseTypeToString(phase); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshGraphicsAddress) -VIR_ENUM_IMPL(vshGraphicsAddress, +VIR_ENUM_DECL(virshGraphicsAddress) +VIR_ENUM_IMPL(virshGraphicsAddress, VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_LAST, N_("IPv4"), N_("IPv6"), N_("unix")) static const char * -vshGraphicsAddressToString(int family) +virshGraphicsAddressToString(int family) { - const char *str = vshGraphicsAddressTypeToString(family); + const char *str = virshGraphicsAddressTypeToString(family); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshDomainBlockJobStatus) -VIR_ENUM_IMPL(vshDomainBlockJobStatus, +VIR_ENUM_DECL(virshDomainBlockJobStatus) +VIR_ENUM_IMPL(virshDomainBlockJobStatus, VIR_DOMAIN_BLOCK_JOB_LAST, N_("completed"), N_("failed"), @@ -11805,35 +11811,35 @@ VIR_ENUM_IMPL(vshDomainBlockJobStatus, N_("ready")) static const char * -vshDomainBlockJobStatusToString(int status) +virshDomainBlockJobStatusToString(int status) { - const char *str = vshDomainBlockJobStatusTypeToString(status); + const char *str = virshDomainBlockJobStatusTypeToString(status); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshDomainEventDiskChange) -VIR_ENUM_IMPL(vshDomainEventDiskChange, +VIR_ENUM_DECL(virshDomainEventDiskChange) +VIR_ENUM_IMPL(virshDomainEventDiskChange, VIR_DOMAIN_EVENT_DISK_CHANGE_LAST, N_("changed"), N_("dropped")) static const char * -vshDomainEventDiskChangeToString(int reason) +virshDomainEventDiskChangeToString(int reason) { - const char *str = vshDomainEventDiskChangeTypeToString(reason); + const char *str = virshDomainEventDiskChangeTypeToString(reason); return str ? _(str) : _("unknown"); } -VIR_ENUM_DECL(vshDomainEventTrayChange) -VIR_ENUM_IMPL(vshDomainEventTrayChange, +VIR_ENUM_DECL(virshDomainEventTrayChange) +VIR_ENUM_IMPL(virshDomainEventTrayChange, VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST, N_("opened"), N_("closed")) static const char * -vshDomainEventTrayChangeToString(int reason) +virshDomainEventTrayChangeToString(int reason) { - const char *str = vshDomainEventTrayChangeTypeToString(reason); + const char *str = virshDomainEventTrayChangeTypeToString(reason); return str ? _(str) : _("unknown"); } @@ -11843,21 +11849,21 @@ struct vshEventCallback { }; typedef struct vshEventCallback vshEventCallback; -struct vshDomEventData { +struct virshDomEventData { vshControl *ctl; bool loop; int *count; vshEventCallback *cb; int id; }; -typedef struct vshDomEventData vshDomEventData; +typedef struct virshDomEventData virshDomEventData; static void -vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - void *opaque) +virshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; @@ -11869,31 +11875,31 @@ vshEventGenericPrint(virConnectPtr conn ATTRIBUTE_UNUSED, } static void -vshEventLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - int event, - int detail, - void *opaque) +virshEventLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + int event, + int detail, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'lifecycle' for domain %s: %s %s\n"), - virDomainGetName(dom), vshDomainEventToString(event), - vshDomainEventDetailToString(event, detail)); + virDomainGetName(dom), virshDomainEventToString(event), + virshDomainEventDetailToString(event, detail)); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventRTCChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - long long utcoffset, - void *opaque) +virshEventRTCChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + long long utcoffset, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; @@ -11905,63 +11911,63 @@ vshEventRTCChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, } static void -vshEventWatchdogPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - int action, - void *opaque) +virshEventWatchdogPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + int action, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'watchdog' for domain %s: %s\n"), - virDomainGetName(dom), vshDomainEventWatchdogToString(action)); + virDomainGetName(dom), virshDomainEventWatchdogToString(action)); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventIOErrorPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - const char *srcPath, - const char *devAlias, - int action, - void *opaque) +virshEventIOErrorPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *srcPath, + const char *devAlias, + int action, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'io-error' for domain %s: %s (%s) %s\n"), virDomainGetName(dom), srcPath, devAlias, - vshDomainEventIOErrorToString(action)); + virshDomainEventIOErrorToString(action)); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventGraphicsPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - int phase, - const virDomainEventGraphicsAddress *local, - const virDomainEventGraphicsAddress *remote, - const char *authScheme, - const virDomainEventGraphicsSubject *subject, - void *opaque) -{ - vshDomEventData *data = opaque; +virshEventGraphicsPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + int phase, + const virDomainEventGraphicsAddress *local, + const virDomainEventGraphicsAddress *remote, + const char *authScheme, + const virDomainEventGraphicsSubject *subject, + void *opaque) +{ + virshDomEventData *data = opaque; size_t i; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'graphics' for domain %s: " "%s local[%s %s %s] remote[%s %s %s] %s"), - virDomainGetName(dom), vshGraphicsPhaseToString(phase), - vshGraphicsAddressToString(local->family), + virDomainGetName(dom), virshGraphicsPhaseToString(phase), + virshGraphicsAddressToString(local->family), local->node, local->service, - vshGraphicsAddressToString(remote->family), + virshGraphicsAddressToString(remote->family), remote->node, remote->service, authScheme); for (i = 0; i < subject->nidentity; i++) @@ -11974,108 +11980,108 @@ vshEventGraphicsPrint(virConnectPtr conn ATTRIBUTE_UNUSED, } static void -vshEventIOErrorReasonPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - const char *srcPath, - const char *devAlias, - int action, - const char *reason, - void *opaque) +virshEventIOErrorReasonPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *srcPath, + const char *devAlias, + int action, + const char *reason, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'io-error-reason' for domain %s: " "%s (%s) %s due to %s\n"), virDomainGetName(dom), srcPath, devAlias, - vshDomainEventIOErrorToString(action), reason); + virshDomainEventIOErrorToString(action), reason); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventBlockJobPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - const char *disk, - int type, - int status, - void *opaque) +virshEventBlockJobPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *disk, + int type, + int status, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event '%s' for domain %s: %s for %s %s\n"), data->cb->name, virDomainGetName(dom), - vshDomainBlockJobToString(type), - disk, vshDomainBlockJobStatusToString(status)); + virshDomainBlockJobToString(type), + disk, virshDomainBlockJobStatusToString(status)); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventDiskChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - const char *oldSrc, - const char *newSrc, - const char *alias, - int reason, - void *opaque) +virshEventDiskChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *oldSrc, + const char *newSrc, + const char *alias, + int reason, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'disk-change' for domain %s disk %s: %s -> %s: %s\n"), virDomainGetName(dom), alias, NULLSTR(oldSrc), NULLSTR(newSrc), - vshDomainEventDiskChangeToString(reason)); + virshDomainEventDiskChangeToString(reason)); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventTrayChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - const char *alias, - int reason, - void *opaque) +virshEventTrayChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *alias, + int reason, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'tray-change' for domain %s disk %s: %s\n"), virDomainGetName(dom), alias, - vshDomainEventTrayChangeToString(reason)); + virshDomainEventTrayChangeToString(reason)); (*data->count)++; if (!data->loop) vshEventDone(data->ctl); } static void -vshEventPMChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - int reason ATTRIBUTE_UNUSED, - void *opaque) +virshEventPMChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + int reason ATTRIBUTE_UNUSED, + void *opaque) { /* As long as libvirt.h doesn't define any reasons, we might as * well treat all PM state changes as generic events. */ - vshEventGenericPrint(conn, dom, opaque); + virshEventGenericPrint(conn, dom, opaque); } static void -vshEventBalloonChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - unsigned long long actual, - void *opaque) +virshEventBalloonChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + unsigned long long actual, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; @@ -12088,12 +12094,12 @@ vshEventBalloonChangePrint(virConnectPtr conn ATTRIBUTE_UNUSED, } static void -vshEventDeviceRemovedPrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - const char *alias, - void *opaque) +virshEventDeviceRemovedPrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + const char *alias, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; @@ -12106,12 +12112,12 @@ vshEventDeviceRemovedPrint(virConnectPtr conn ATTRIBUTE_UNUSED, } static void -vshEventDeviceAddedPrint(virConnectPtr conn ATTRIBUTE_UNUSED, +virshEventDeviceAddedPrint(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, const char *alias, void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; @@ -12124,13 +12130,13 @@ vshEventDeviceAddedPrint(virConnectPtr conn ATTRIBUTE_UNUSED, } static void -vshEventTunablePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - virTypedParameterPtr params, - int nparams, - void *opaque) +virshEventTunablePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + virTypedParameterPtr params, + int nparams, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; size_t i; char *value = NULL; @@ -12154,15 +12160,15 @@ vshEventTunablePrint(virConnectPtr conn ATTRIBUTE_UNUSED, vshEventDone(data->ctl); } -VIR_ENUM_DECL(vshEventAgentLifecycleState) -VIR_ENUM_IMPL(vshEventAgentLifecycleState, +VIR_ENUM_DECL(virshEventAgentLifecycleState) +VIR_ENUM_IMPL(virshEventAgentLifecycleState, VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_LAST, N_("unknown"), N_("connected"), N_("disconnected")) -VIR_ENUM_DECL(vshEventAgentLifecycleReason) -VIR_ENUM_IMPL(vshEventAgentLifecycleReason, +VIR_ENUM_DECL(virshEventAgentLifecycleReason) +VIR_ENUM_IMPL(virshEventAgentLifecycleReason, VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_LAST, N_("unknown"), N_("domain started"), @@ -12170,21 +12176,21 @@ VIR_ENUM_IMPL(vshEventAgentLifecycleReason, #define UNKNOWNSTR(str) (str ? str : N_("unsupported value")) static void -vshEventAgentLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED, - virDomainPtr dom, - int state, - int reason, - void *opaque) +virshEventAgentLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED, + virDomainPtr dom, + int state, + int reason, + void *opaque) { - vshDomEventData *data = opaque; + virshDomEventData *data = opaque; if (!data->loop && *data->count) return; vshPrint(data->ctl, _("event 'agent-lifecycle' for domain %s: state: '%s' reason: '%s'\n"), virDomainGetName(dom), - UNKNOWNSTR(vshEventAgentLifecycleStateTypeToString(state)), - UNKNOWNSTR(vshEventAgentLifecycleReasonTypeToString(reason))); + UNKNOWNSTR(virshEventAgentLifecycleStateTypeToString(state)), + UNKNOWNSTR(virshEventAgentLifecycleReasonTypeToString(reason))); (*data->count)++; if (!data->loop) @@ -12193,43 +12199,43 @@ vshEventAgentLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED, static vshEventCallback vshEventCallbacks[] = { { "lifecycle", - VIR_DOMAIN_EVENT_CALLBACK(vshEventLifecyclePrint), }, - { "reboot", vshEventGenericPrint, }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventLifecyclePrint), }, + { "reboot", virshEventGenericPrint, }, { "rtc-change", - VIR_DOMAIN_EVENT_CALLBACK(vshEventRTCChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventRTCChangePrint), }, { "watchdog", - VIR_DOMAIN_EVENT_CALLBACK(vshEventWatchdogPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventWatchdogPrint), }, { "io-error", - VIR_DOMAIN_EVENT_CALLBACK(vshEventIOErrorPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventIOErrorPrint), }, { "graphics", - VIR_DOMAIN_EVENT_CALLBACK(vshEventGraphicsPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventGraphicsPrint), }, { "io-error-reason", - VIR_DOMAIN_EVENT_CALLBACK(vshEventIOErrorReasonPrint), }, - { "control-error", vshEventGenericPrint, }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventIOErrorReasonPrint), }, + { "control-error", virshEventGenericPrint, }, { "block-job", - VIR_DOMAIN_EVENT_CALLBACK(vshEventBlockJobPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventBlockJobPrint), }, { "disk-change", - VIR_DOMAIN_EVENT_CALLBACK(vshEventDiskChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventDiskChangePrint), }, { "tray-change", - VIR_DOMAIN_EVENT_CALLBACK(vshEventTrayChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventTrayChangePrint), }, { "pm-wakeup", - VIR_DOMAIN_EVENT_CALLBACK(vshEventPMChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventPMChangePrint), }, { "pm-suspend", - VIR_DOMAIN_EVENT_CALLBACK(vshEventPMChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventPMChangePrint), }, { "balloon-change", - VIR_DOMAIN_EVENT_CALLBACK(vshEventBalloonChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventBalloonChangePrint), }, { "pm-suspend-disk", - VIR_DOMAIN_EVENT_CALLBACK(vshEventPMChangePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventPMChangePrint), }, { "device-removed", - VIR_DOMAIN_EVENT_CALLBACK(vshEventDeviceRemovedPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventDeviceRemovedPrint), }, { "block-job-2", - VIR_DOMAIN_EVENT_CALLBACK(vshEventBlockJobPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventBlockJobPrint), }, { "tunable", - VIR_DOMAIN_EVENT_CALLBACK(vshEventTunablePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventTunablePrint), }, { "agent-lifecycle", - VIR_DOMAIN_EVENT_CALLBACK(vshEventAgentLifecyclePrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventAgentLifecyclePrint), }, { "device-added", - VIR_DOMAIN_EVENT_CALLBACK(vshEventDeviceAddedPrint), }, + VIR_DOMAIN_EVENT_CALLBACK(virshEventDeviceAddedPrint), }, }; verify(VIR_DOMAIN_EVENT_ID_LAST == ARRAY_CARDINALITY(vshEventCallbacks)); @@ -12277,7 +12283,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom = NULL; bool ret = false; int timeout = 0; - vshDomEventData *data = NULL; + virshDomEventData *data = NULL; size_t i; const char *eventName = NULL; int event = -1; @@ -12461,7 +12467,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) xmlNodePtr disk_node = NULL; char *disk_xml = NULL; bool ret = false; - vshUpdateDiskXMLType update_type; + virshUpdateDiskXMLType update_type; const char *action = NULL; const char *success_msg = NULL; bool config = vshCommandOptBool(cmd, "config"); @@ -12530,11 +12536,11 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) if (!doc) goto cleanup; - if (!(disk_node = vshFindDisk(doc, path, VIRSH_FIND_DISK_CHANGEABLE))) + if (!(disk_node = virshFindDisk(doc, path, VIRSH_FIND_DISK_CHANGEABLE))) goto cleanup; - if (!(disk_xml = vshUpdateDiskXML(disk_node, source, block, path, - update_type))) + if (!(disk_xml = virshUpdateDiskXML(disk_node, source, block, path, + update_type))) goto cleanup; if (vshCommandOptBool(cmd, "print-xml")) { diff --git a/tools/virsh-domain.h b/tools/virsh-domain.h index 2f3ec30..462f560 100644 --- a/tools/virsh-domain.h +++ b/tools/virsh-domain.h @@ -37,7 +37,8 @@ virDomainPtr virshCommandOptDomainBy(vshControl *ctl, const vshCmd *cmd, /* default is lookup by Id, Name and UUID */ # define virshCommandOptDomain(_ctl, _cmd, _name) \ - virshCommandOptDomainBy(_ctl, _cmd, _name, VSH_BYID|VSH_BYUUID|VSH_BYNAME) + virshCommandOptDomainBy(_ctl, _cmd, _name, \ + VIRSH_BYID | VIRSH_BYUUID | VIRSH_BYNAME) extern const vshCmdDef domManagementCmds[]; diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c index 49d4a5a..1b39cb7 100644 --- a/tools/virsh-edit.c +++ b/tools/virsh-edit.c @@ -70,7 +70,7 @@ do { goto edit_cleanup; /* Create and open the temporary file. */ - tmp = virshEditWriteToTempFile(ctl, doc); + tmp = vshEditWriteToTempFile(ctl, doc); if (!tmp) goto edit_cleanup; @@ -81,12 +81,12 @@ do { #endif /* Start the editor. */ - if (virshEditFile(ctl, tmp) == -1) + if (vshEditFile(ctl, tmp) == -1) goto edit_cleanup; /* Read back the edited file. */ VIR_FREE(doc_edited); - doc_edited = virshEditReadBackFile(ctl, tmp); + doc_edited = vshEditReadBackFile(ctl, tmp); if (!doc_edited) goto edit_cleanup; @@ -118,7 +118,7 @@ do { msg = _("Failed."); if (msg) { - int c = virshAskReedit(ctl, msg, relax_avail); + int c = vshAskReedit(ctl, msg, relax_avail); switch (c) { case 'y': goto reedit; diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 9a00070..b69c685 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -49,7 +49,7 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd, const char *n = NULL; bool is_mac = false; virMacAddr dummy; - virCheckFlags(VSH_BYNAME | VSH_BYMAC, NULL); + virCheckFlags(VIRSH_BYNAME | VIRSH_BYMAC, NULL); virshControlPtr priv = ctl->privData; if (!optname) @@ -68,13 +68,13 @@ virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd, is_mac = true; /* try it by NAME */ - if (!is_mac && (flags & VSH_BYNAME)) { + if (!is_mac && (flags & VIRSH_BYNAME)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface NAME\n", cmd->def->name, optname); iface = virInterfaceLookupByName(priv->conn, n); /* try it by MAC */ - } else if (is_mac && (flags & VSH_BYMAC)) { + } else if (is_mac && (flags & VIRSH_BYMAC)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as interface MAC\n", cmd->def->name, optname); iface = virInterfaceLookupByMACString(priv->conn, n); @@ -148,7 +148,7 @@ cmdInterfaceEdit(vshControl *ctl, const vshCmd *cmd) } static int -vshInterfaceSorter(const void *a, const void *b) +virshInterfaceSorter(const void *a, const void *b) { virInterfacePtr *ia = (virInterfacePtr *) a; virInterfacePtr *ib = (virInterfacePtr *) b; @@ -163,14 +163,14 @@ vshInterfaceSorter(const void *a, const void *b) virInterfaceGetName(*ib)); } -struct vshInterfaceList { +struct virshInterfaceList { virInterfacePtr *ifaces; size_t nifaces; }; -typedef struct vshInterfaceList *vshInterfaceListPtr; +typedef struct virshInterfaceList *virshInterfaceListPtr; static void -vshInterfaceListFree(vshInterfaceListPtr list) +virshInterfaceListFree(virshInterfaceListPtr list) { size_t i; @@ -184,11 +184,11 @@ vshInterfaceListFree(vshInterfaceListPtr list) VIR_FREE(list); } -static vshInterfaceListPtr -vshInterfaceListCollect(vshControl *ctl, - unsigned int flags) +static virshInterfaceListPtr +virshInterfaceListCollect(vshControl *ctl, + unsigned int flags) { - vshInterfaceListPtr list = vshMalloc(ctl, sizeof(*list)); + virshInterfaceListPtr list = vshMalloc(ctl, sizeof(*list)); size_t i; int ret; char **activeNames = NULL; @@ -292,7 +292,7 @@ vshInterfaceListCollect(vshControl *ctl, /* sort the list */ if (list->ifaces && list->nifaces) qsort(list->ifaces, list->nifaces, - sizeof(*list->ifaces), vshInterfaceSorter); + sizeof(*list->ifaces), virshInterfaceSorter); /* truncate the list if filter simulation deleted entries */ if (deleted) @@ -311,7 +311,7 @@ vshInterfaceListCollect(vshControl *ctl, VIR_FREE(inactiveNames); if (!success) { - vshInterfaceListFree(list); + virshInterfaceListFree(list); list = NULL; } @@ -349,7 +349,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) bool inactive = vshCommandOptBool(cmd, "inactive"); bool all = vshCommandOptBool(cmd, "all"); unsigned int flags = VIR_CONNECT_LIST_INTERFACES_ACTIVE; - vshInterfaceListPtr list = NULL; + virshInterfaceListPtr list = NULL; size_t i; if (inactive) @@ -358,7 +358,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) flags = VIR_CONNECT_LIST_INTERFACES_INACTIVE | VIR_CONNECT_LIST_INTERFACES_ACTIVE; - if (!(list = vshInterfaceListCollect(ctl, flags))) + if (!(list = virshInterfaceListCollect(ctl, flags))) return false; vshPrintExtra(ctl, " %-20s %-10s %s\n", _("Name"), _("State"), @@ -374,7 +374,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) virInterfaceGetMACString(iface)); } - vshInterfaceListFree(list); + virshInterfaceListFree(list); return true; } @@ -406,7 +406,7 @@ cmdInterfaceName(vshControl *ctl, const vshCmd *cmd) virInterfacePtr iface; if (!(iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, - VSH_BYMAC))) + VIRSH_BYMAC))) return false; vshPrint(ctl, "%s\n", virInterfaceGetName(iface)); @@ -442,7 +442,7 @@ cmdInterfaceMAC(vshControl *ctl, const vshCmd *cmd) virInterfacePtr iface; if (!(iface = virshCommandOptInterfaceBy(ctl, cmd, NULL, NULL, - VSH_BYNAME))) + VIRSH_BYNAME))) return false; vshPrint(ctl, "%s\n", virInterfaceGetMACString(iface)); @@ -538,7 +538,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; iface = virInterfaceDefineXML(priv->conn, buffer, 0); @@ -837,7 +837,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* Get a handle to the original device */ if (!(if_handle = virshCommandOptInterfaceBy(ctl, cmd, "interface", - &if_name, VSH_BYNAME))) { + &if_name, VIRSH_BYNAME))) { goto cleanup; } @@ -1058,7 +1058,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) /* Get a handle to the original device */ if (!(br_handle = virshCommandOptInterfaceBy(ctl, cmd, "bridge", - &br_name, VSH_BYNAME))) { + &br_name, VIRSH_BYNAME))) { goto cleanup; } diff --git a/tools/virsh-interface.h b/tools/virsh-interface.h index be756ec..44bf5e4 100644 --- a/tools/virsh-interface.h +++ b/tools/virsh-interface.h @@ -35,7 +35,7 @@ virInterfacePtr virshCommandOptInterfaceBy(vshControl *ctl, const vshCmd *cmd, /* default is lookup by Name and MAC */ # define virshCommandOptInterface(_ctl, _cmd, _name) \ virshCommandOptInterfaceBy(_ctl, _cmd, NULL, _name, \ - VSH_BYMAC|VSH_BYNAME) + VIRSH_BYMAC | VIRSH_BYNAME) extern const vshCmdDef ifaceCmds[]; diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 4e3eee5..00a50ef 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -40,7 +40,7 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd, virNetworkPtr network = NULL; const char *n = NULL; const char *optname = "network"; - virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL); + virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); virshControlPtr priv = ctl->privData; if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) @@ -53,13 +53,13 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd, *name = n; /* try it by UUID */ - if ((flags & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) { + if ((flags & VIRSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as network UUID\n", cmd->def->name, optname); network = virNetworkLookupByUUIDString(priv->conn, n); } /* try it by NAME */ - if (!network && (flags & VSH_BYNAME)) { + if (!network && (flags & VIRSH_BYNAME)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as network NAME\n", cmd->def->name, optname); network = virNetworkLookupByName(priv->conn, n); @@ -161,7 +161,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; network = virNetworkCreateXML(priv->conn, buffer); @@ -213,7 +213,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; network = virNetworkDefineXML(priv->conn, buffer); @@ -393,7 +393,7 @@ cmdNetworkInfo(vshControl *ctl, const vshCmd *cmd) } static int -vshNetworkSorter(const void *a, const void *b) +virshNetworkSorter(const void *a, const void *b) { virNetworkPtr *na = (virNetworkPtr *) a; virNetworkPtr *nb = (virNetworkPtr *) b; @@ -408,14 +408,14 @@ vshNetworkSorter(const void *a, const void *b) virNetworkGetName(*nb)); } -struct vshNetworkList { +struct virshNetworkList { virNetworkPtr *nets; size_t nnets; }; -typedef struct vshNetworkList *vshNetworkListPtr; +typedef struct virshNetworkList *virshNetworkListPtr; static void -vshNetworkListFree(vshNetworkListPtr list) +virshNetworkListFree(virshNetworkListPtr list) { size_t i; @@ -429,11 +429,11 @@ vshNetworkListFree(vshNetworkListPtr list) VIR_FREE(list); } -static vshNetworkListPtr -vshNetworkListCollect(vshControl *ctl, - unsigned int flags) +static virshNetworkListPtr +virshNetworkListCollect(vshControl *ctl, + unsigned int flags) { - vshNetworkListPtr list = vshMalloc(ctl, sizeof(*list)); + virshNetworkListPtr list = vshMalloc(ctl, sizeof(*list)); size_t i; int ret; char **names = NULL; @@ -589,7 +589,7 @@ vshNetworkListCollect(vshControl *ctl, /* sort the list */ if (list->nets && list->nnets) qsort(list->nets, list->nnets, - sizeof(*list->nets), vshNetworkSorter); + sizeof(*list->nets), virshNetworkSorter); /* truncate the list if filter simulation deleted entries */ if (deleted) @@ -603,7 +603,7 @@ vshNetworkListCollect(vshControl *ctl, VIR_FREE(names); if (!success) { - vshNetworkListFree(list); + virshNetworkListFree(list); list = NULL; } @@ -669,7 +669,7 @@ static const vshCmdOptDef opts_network_list[] = { static bool cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { - vshNetworkListPtr list = NULL; + virshNetworkListPtr list = NULL; size_t i; bool ret = false; bool optName = vshCommandOptBool(cmd, "name"); @@ -701,7 +701,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) if (!optUUID && !optName) optTable = true; - if (!(list = vshNetworkListCollect(ctl, flags))) + if (!(list = virshNetworkListCollect(ctl, flags))) return false; if (optTable) { @@ -740,7 +740,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ret = true; cleanup: - vshNetworkListFree(list); + virshNetworkListFree(list); return ret; } #undef FILTER @@ -773,7 +773,7 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd) virNetworkPtr network; if (!(network = virshCommandOptNetworkBy(ctl, cmd, NULL, - VSH_BYUUID))) + VIRSH_BYUUID))) return false; vshPrint(ctl, "%s\n", virNetworkGetName(network)); @@ -990,7 +990,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) /* contents of xmldata is actually the name of a file that * contains the xml. */ - if (virFileReadAll(xml, VIRSH_MAX_XML_FILE, &xmlFromFile) < 0) + if (virFileReadAll(xml, VSH_MAX_XML_FILE, &xmlFromFile) < 0) goto cleanup; /* NB: the original xml is just a const char * that points * to a string owned by the vshCmd object, and will be freed @@ -1071,7 +1071,7 @@ cmdNetworkUuid(vshControl *ctl, const vshCmd *cmd) char uuid[VIR_UUID_STRING_BUFLEN]; if (!(network = virshCommandOptNetworkBy(ctl, cmd, NULL, - VSH_BYNAME))) + VIRSH_BYNAME))) return false; if (virNetworkGetUUIDString(network, uuid) != -1) @@ -1105,7 +1105,7 @@ static const vshCmdOptDef opts_network_edit[] = { {.name = NULL} }; -static char *vshNetworkGetXMLDesc(virNetworkPtr network) +static char *virshNetworkGetXMLDesc(virNetworkPtr network) { unsigned int flags = VIR_NETWORK_XML_INACTIVE; char *doc = virNetworkGetXMLDesc(network, flags); @@ -1133,7 +1133,7 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd) if (network == NULL) goto cleanup; -#define EDIT_GET_XML vshNetworkGetXMLDesc(network) +#define EDIT_GET_XML virshNetworkGetXMLDesc(network) #define EDIT_NOT_CHANGED \ do { \ vshPrint(ctl, _("Network %s XML configuration not changed.\n"), \ @@ -1163,8 +1163,8 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd) /* * "net-event" command */ -VIR_ENUM_DECL(vshNetworkEvent) -VIR_ENUM_IMPL(vshNetworkEvent, +VIR_ENUM_DECL(virshNetworkEvent) +VIR_ENUM_IMPL(virshNetworkEvent, VIR_NETWORK_EVENT_LAST, N_("Defined"), N_("Undefined"), @@ -1172,21 +1172,21 @@ VIR_ENUM_IMPL(vshNetworkEvent, N_("Stopped")) static const char * -vshNetworkEventToString(int event) +virshNetworkEventToString(int event) { - const char *str = vshNetworkEventTypeToString(event); + const char *str = virshNetworkEventTypeToString(event); return str ? _(str) : _("unknown"); } -struct vshNetEventData { +struct virshNetEventData { vshControl *ctl; bool loop; int count; }; -typedef struct vshNetEventData vshNetEventData; +typedef struct virshNetEventData virshNetEventData; -VIR_ENUM_DECL(vshNetworkEventId) -VIR_ENUM_IMPL(vshNetworkEventId, +VIR_ENUM_DECL(virshNetworkEventId) +VIR_ENUM_IMPL(virshNetworkEventId, VIR_NETWORK_EVENT_ID_LAST, "lifecycle") @@ -1197,12 +1197,12 @@ vshEventLifecyclePrint(virConnectPtr conn ATTRIBUTE_UNUSED, int detail ATTRIBUTE_UNUSED, void *opaque) { - vshNetEventData *data = opaque; + virshNetEventData *data = opaque; if (!data->loop && data->count) return; vshPrint(data->ctl, _("event 'lifecycle' for network %s: %s\n"), - virNetworkGetName(net), vshNetworkEventToString(event)); + virNetworkGetName(net), virshNetworkEventToString(event)); data->count++; if (!data->loop) vshEventDone(data->ctl); @@ -1249,7 +1249,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd) bool ret = false; int eventId = -1; int timeout = 0; - vshNetEventData data; + virshNetEventData data; const char *eventName = NULL; int event; virshControlPtr priv = ctl->privData; @@ -1258,7 +1258,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd) size_t i; for (i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) - vshPrint(ctl, "%s\n", vshNetworkEventIdTypeToString(i)); + vshPrint(ctl, "%s\n", virshNetworkEventIdTypeToString(i)); return true; } @@ -1268,7 +1268,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "%s", _("either --list or event type is required")); return false; } - if ((event = vshNetworkEventIdTypeFromString(eventName)) < 0) { + if ((event = virshNetworkEventIdTypeFromString(eventName)) < 0) { vshError(ctl, _("unknown event type %s"), eventName); return false; } @@ -1343,7 +1343,7 @@ static const vshCmdOptDef opts_network_dhcp_leases[] = { }; static int -vshNetworkDHCPLeaseSorter(const void *a, const void *b) +virshNetworkDHCPLeaseSorter(const void *a, const void *b) { int rv = -1; @@ -1384,7 +1384,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd) } /* Sort the list according to MAC Address/IAID */ - qsort(leases, nleases, sizeof(*leases), vshNetworkDHCPLeaseSorter); + qsort(leases, nleases, sizeof(*leases), virshNetworkDHCPLeaseSorter); vshPrintExtra(ctl, " %-20s %-18s %-9s %-25s %-15s %s\n%s%s\n", _("Expiry Time"), _("MAC address"), _("Protocol"), diff --git a/tools/virsh-network.h b/tools/virsh-network.h index 49823a8..92bb4b5 100644 --- a/tools/virsh-network.h +++ b/tools/virsh-network.h @@ -35,7 +35,7 @@ virshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd, /* default is lookup by Name and UUID */ # define virshCommandOptNetwork(_ctl, _cmd, _name) \ virshCommandOptNetworkBy(_ctl, _cmd, _name, \ - VSH_BYUUID|VSH_BYNAME) + VIRSH_BYUUID | VIRSH_BYNAME) extern const vshCmdDef networkCmds[]; diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index d81afcf..cc359e2 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -70,7 +70,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; dev = virNodeDeviceCreateXML(priv->conn, buffer, 0); @@ -164,22 +164,22 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd) return ret; } -struct vshNodeList { +struct virshNodeList { char **names; char **parents; }; static const char * -vshNodeListLookup(int devid, bool parent, void *opaque) +virshNodeListLookup(int devid, bool parent, void *opaque) { - struct vshNodeList *arrays = opaque; + struct virshNodeList *arrays = opaque; if (parent) return arrays->parents[devid]; return arrays->names[devid]; } static int -vshNodeDeviceSorter(const void *a, const void *b) +virshNodeDeviceSorter(const void *a, const void *b) { virNodeDevicePtr *na = (virNodeDevicePtr *) a; virNodeDevicePtr *nb = (virNodeDevicePtr *) b; @@ -194,14 +194,14 @@ vshNodeDeviceSorter(const void *a, const void *b) virNodeDeviceGetName(*nb)); } -struct vshNodeDeviceList { +struct virshNodeDeviceList { virNodeDevicePtr *devices; size_t ndevices; }; -typedef struct vshNodeDeviceList *vshNodeDeviceListPtr; +typedef struct virshNodeDeviceList *virshNodeDeviceListPtr; static void -vshNodeDeviceListFree(vshNodeDeviceListPtr list) +virshNodeDeviceListFree(virshNodeDeviceListPtr list) { size_t i; @@ -215,13 +215,13 @@ vshNodeDeviceListFree(vshNodeDeviceListPtr list) VIR_FREE(list); } -static vshNodeDeviceListPtr -vshNodeDeviceListCollect(vshControl *ctl, +static virshNodeDeviceListPtr +virshNodeDeviceListCollect(vshControl *ctl, char **capnames, int ncapnames, unsigned int flags) { - vshNodeDeviceListPtr list = vshMalloc(ctl, sizeof(*list)); + virshNodeDeviceListPtr list = vshMalloc(ctl, sizeof(*list)); size_t i; int ret; virNodeDevicePtr device; @@ -339,7 +339,7 @@ vshNodeDeviceListCollect(vshControl *ctl, /* sort the list */ if (list->devices && list->ndevices) qsort(list->devices, list->ndevices, - sizeof(*list->devices), vshNodeDeviceSorter); + sizeof(*list->devices), virshNodeDeviceSorter); /* truncate the list if filter simulation deleted entries */ if (deleted) @@ -353,7 +353,7 @@ vshNodeDeviceListCollect(vshControl *ctl, VIR_FREE(names); if (!success) { - vshNodeDeviceListFree(list); + virshNodeDeviceListFree(list); list = NULL; } @@ -395,7 +395,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) unsigned int flags = 0; char **caps = NULL; int ncaps = 0; - vshNodeDeviceListPtr list = NULL; + virshNodeDeviceListPtr list = NULL; int cap_type = -1; ignore_value(vshCommandOptString(ctl, cmd, "cap", &cap_str)); @@ -458,7 +458,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) } } - if (!(list = vshNodeDeviceListCollect(ctl, caps, ncaps, flags))) { + if (!(list = virshNodeDeviceListCollect(ctl, caps, ncaps, flags))) { ret = false; goto cleanup; } @@ -466,7 +466,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) if (tree) { char **parents = vshMalloc(ctl, sizeof(char *) * list->ndevices); char **names = vshMalloc(ctl, sizeof(char *) * list->ndevices); - struct vshNodeList arrays = { names, parents }; + struct virshNodeList arrays = { names, parents }; for (i = 0; i < list->ndevices; i++) names[i] = vshStrdup(ctl, virNodeDeviceGetName(list->devices[i])); @@ -483,8 +483,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) for (i = 0; i < list->ndevices; i++) { if (parents[i] == NULL && - virshTreePrint(ctl, vshNodeListLookup, &arrays, - list->ndevices, i) < 0) + vshTreePrint(ctl, virshNodeListLookup, &arrays, + list->ndevices, i) < 0) ret = false; } @@ -501,7 +501,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cleanup: virStringFreeList(caps); - vshNodeDeviceListFree(list); + virshNodeDeviceListFree(list); return ret; } diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 8c64ac4..7732da8 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -41,7 +41,7 @@ virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, const char *optname = "nwfilter"; virshControlPtr priv = ctl->privData; - virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL); + virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) return NULL; @@ -53,13 +53,13 @@ virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, *name = n; /* try it by UUID */ - if ((flags & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) { + if ((flags & VIRSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as nwfilter UUID\n", cmd->def->name, optname); nwfilter = virNWFilterLookupByUUIDString(priv->conn, n); } /* try it by NAME */ - if (!nwfilter && (flags & VSH_BYNAME)) { + if (!nwfilter && (flags & VIRSH_BYNAME)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as nwfilter NAME\n", cmd->def->name, optname); nwfilter = virNWFilterLookupByName(priv->conn, n); @@ -105,7 +105,7 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; nwfilter = virNWFilterDefineXML(priv->conn, buffer); @@ -210,7 +210,7 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd) } static int -vshNWFilterSorter(const void *a, const void *b) +virshNWFilterSorter(const void *a, const void *b) { virNWFilterPtr *fa = (virNWFilterPtr *) a; virNWFilterPtr *fb = (virNWFilterPtr *) b; @@ -225,14 +225,14 @@ vshNWFilterSorter(const void *a, const void *b) virNWFilterGetName(*fb)); } -struct vshNWFilterList { +struct virshNWFilterList { virNWFilterPtr *filters; size_t nfilters; }; -typedef struct vshNWFilterList *vshNWFilterListPtr; +typedef struct virshNWFilterList *virshNWFilterListPtr; static void -vshNWFilterListFree(vshNWFilterListPtr list) +virshNWFilterListFree(virshNWFilterListPtr list) { size_t i; @@ -246,11 +246,11 @@ vshNWFilterListFree(vshNWFilterListPtr list) VIR_FREE(list); } -static vshNWFilterListPtr -vshNWFilterListCollect(vshControl *ctl, - unsigned int flags) +static virshNWFilterListPtr +virshNWFilterListCollect(vshControl *ctl, + unsigned int flags) { - vshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list)); + virshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list)); size_t i; int ret; virNWFilterPtr filter; @@ -317,7 +317,7 @@ vshNWFilterListCollect(vshControl *ctl, /* sort the list */ if (list->filters && list->nfilters) qsort(list->filters, list->nfilters, - sizeof(*list->filters), vshNWFilterSorter); + sizeof(*list->filters), virshNWFilterSorter); /* truncate the list for not found filter objects */ if (deleted) @@ -331,7 +331,7 @@ vshNWFilterListCollect(vshControl *ctl, VIR_FREE(names); if (!success) { - vshNWFilterListFree(list); + virshNWFilterListFree(list); list = NULL; } @@ -360,9 +360,9 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; - vshNWFilterListPtr list = NULL; + virshNWFilterListPtr list = NULL; - if (!(list = vshNWFilterListCollect(ctl, 0))) + if (!(list = virshNWFilterListCollect(ctl, 0))) return false; vshPrintExtra(ctl, " %-36s %-20s \n", _("UUID"), _("Name")); @@ -378,7 +378,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) virNWFilterGetName(nwfilter)); } - vshNWFilterListFree(list); + virshNWFilterListFree(list); return true; } diff --git a/tools/virsh-nwfilter.h b/tools/virsh-nwfilter.h index a570813..1e4250e 100644 --- a/tools/virsh-nwfilter.h +++ b/tools/virsh-nwfilter.h @@ -35,7 +35,7 @@ virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, /* default is lookup by Name and UUID */ # define virshCommandOptNWFilter(_ctl, _cmd, _name) \ virshCommandOptNWFilterBy(_ctl, _cmd, _name, \ - VSH_BYUUID|VSH_BYNAME) + VIRSH_BYUUID | VIRSH_BYNAME) extern const vshCmdDef nwfilterCmds[]; diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index f87b73c..cf5a8f3 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -41,7 +41,7 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, const char *n = NULL; virshControlPtr priv = ctl->privData; - virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL); + virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) return NULL; @@ -53,13 +53,13 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, *name = n; /* try it by UUID */ - if ((flags & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) { + if ((flags & VIRSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as pool UUID\n", cmd->def->name, optname); pool = virStoragePoolLookupByUUIDString(priv->conn, n); } /* try it by NAME */ - if (!pool && (flags & VSH_BYNAME)) { + if (!pool && (flags & VIRSH_BYNAME)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as pool NAME\n", cmd->def->name, optname); pool = virStoragePoolLookupByName(priv->conn, n); @@ -161,7 +161,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; pool = virStoragePoolCreateXML(priv->conn, buffer, 0); @@ -252,10 +252,10 @@ static const vshCmdOptDef opts_pool_X_as[] = { }; static int -vshBuildPoolXML(vshControl *ctl, - const vshCmd *cmd, - const char **retname, - char **xml) +virshBuildPoolXML(vshControl *ctl, + const vshCmd *cmd, + const char **retname, + char **xml) { const char *name = NULL, *type = NULL, *srcHost = NULL, *srcPath = NULL, *srcDev = NULL, *srcName = NULL, *srcFormat = NULL, @@ -370,7 +370,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd) bool printXML = vshCommandOptBool(cmd, "print-xml"); virshControlPtr priv = ctl->privData; - if (!vshBuildPoolXML(ctl, cmd, &name, &xml)) + if (!virshBuildPoolXML(ctl, cmd, &name, &xml)) return false; if (printXML) { @@ -426,7 +426,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; pool = virStoragePoolDefineXML(priv->conn, buffer, 0); @@ -465,7 +465,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd) bool printXML = vshCommandOptBool(cmd, "print-xml"); virshControlPtr priv = ctl->privData; - if (!vshBuildPoolXML(ctl, cmd, &name, &xml)) + if (!virshBuildPoolXML(ctl, cmd, &name, &xml)) return false; if (printXML) { @@ -728,7 +728,7 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd) } static int -vshStoragePoolSorter(const void *a, const void *b) +virshStoragePoolSorter(const void *a, const void *b) { virStoragePoolPtr *pa = (virStoragePoolPtr *) a; virStoragePoolPtr *pb = (virStoragePoolPtr *) b; @@ -743,14 +743,14 @@ vshStoragePoolSorter(const void *a, const void *b) virStoragePoolGetName(*pb)); } -struct vshStoragePoolList { +struct virshStoragePoolList { virStoragePoolPtr *pools; size_t npools; }; -typedef struct vshStoragePoolList *vshStoragePoolListPtr; +typedef struct virshStoragePoolList *virshStoragePoolListPtr; static void -vshStoragePoolListFree(vshStoragePoolListPtr list) +virshStoragePoolListFree(virshStoragePoolListPtr list) { size_t i; @@ -764,11 +764,11 @@ vshStoragePoolListFree(vshStoragePoolListPtr list) VIR_FREE(list); } -static vshStoragePoolListPtr -vshStoragePoolListCollect(vshControl *ctl, - unsigned int flags) +static virshStoragePoolListPtr +virshStoragePoolListCollect(vshControl *ctl, + unsigned int flags) { - vshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list)); + virshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list)); size_t i; int ret; char **names = NULL; @@ -931,7 +931,7 @@ vshStoragePoolListCollect(vshControl *ctl, /* sort the list */ if (list->pools && list->npools) qsort(list->pools, list->npools, - sizeof(*list->pools), vshStoragePoolSorter); + sizeof(*list->pools), virshStoragePoolSorter); /* truncate the list if filter simulation deleted entries */ if (deleted) @@ -944,7 +944,7 @@ vshStoragePoolListCollect(vshControl *ctl, VIR_FREE(names[i]); if (!success) { - vshStoragePoolListFree(list); + virshStoragePoolListFree(list); list = NULL; } @@ -1039,7 +1039,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) }; struct poolInfoText *poolInfoTexts = NULL; unsigned int flags = VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE; - vshStoragePoolListPtr list = NULL; + virshStoragePoolListPtr list = NULL; const char *type = NULL; bool details = vshCommandOptBool(cmd, "details"); bool inactive, all; @@ -1129,7 +1129,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) virStringFreeList(poolTypes); } - if (!(list = vshStoragePoolListCollect(ctl, flags))) + if (!(list = virshStoragePoolListCollect(ctl, flags))) goto cleanup; poolInfoTexts = vshCalloc(ctl, list->npools, sizeof(*poolInfoTexts)); @@ -1185,17 +1185,17 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) double val; const char *unit; - val = virshPrettyCapacity(info.capacity, &unit); + val = vshPrettyCapacity(info.capacity, &unit); if (virAsprintf(&poolInfoTexts[i].capacity, "%.2lf %s", val, unit) < 0) goto cleanup; - val = virshPrettyCapacity(info.allocation, &unit); + val = vshPrettyCapacity(info.allocation, &unit); if (virAsprintf(&poolInfoTexts[i].allocation, "%.2lf %s", val, unit) < 0) goto cleanup; - val = virshPrettyCapacity(info.available, &unit); + val = vshPrettyCapacity(info.available, &unit); if (virAsprintf(&poolInfoTexts[i].available, "%.2lf %s", val, unit) < 0) goto cleanup; @@ -1378,7 +1378,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) } VIR_FREE(poolInfoTexts); - vshStoragePoolListFree(list); + virshStoragePoolListFree(list); return ret; } @@ -1512,7 +1512,7 @@ cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED) if (vshCommandOptStringReq(ctl, cmd, "srcSpec", &srcSpecFile) < 0) return false; - if (srcSpecFile && virFileReadAll(srcSpecFile, VIRSH_MAX_XML_FILE, + if (srcSpecFile && virFileReadAll(srcSpecFile, VSH_MAX_XML_FILE, &srcSpec) < 0) return false; @@ -1591,13 +1591,13 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd) if (info.state == VIR_STORAGE_POOL_RUNNING || info.state == VIR_STORAGE_POOL_DEGRADED) { - val = virshPrettyCapacity(info.capacity, &unit); + val = vshPrettyCapacity(info.capacity, &unit); vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit); - val = virshPrettyCapacity(info.allocation, &unit); + val = vshPrettyCapacity(info.allocation, &unit); vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit); - val = virshPrettyCapacity(info.available, &unit); + val = vshPrettyCapacity(info.available, &unit); vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit); } } else { @@ -1635,7 +1635,7 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd) { virStoragePoolPtr pool; - if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYUUID))) + if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYUUID))) return false; vshPrint(ctl, "%s\n", virStoragePoolGetName(pool)); @@ -1757,7 +1757,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd) virStoragePoolPtr pool; char uuid[VIR_UUID_STRING_BUFLEN]; - if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VSH_BYNAME))) + if (!(pool = virshCommandOptPoolBy(ctl, cmd, "pool", NULL, VIRSH_BYNAME))) return false; if (virStoragePoolGetUUIDString(pool, uuid) != -1) diff --git a/tools/virsh-pool.h b/tools/virsh-pool.h index b5b0836..feee176 100644 --- a/tools/virsh-pool.h +++ b/tools/virsh-pool.h @@ -35,7 +35,7 @@ virshCommandOptPoolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, /* default is lookup by Name and UUID */ # define virshCommandOptPool(_ctl, _cmd, _optname, _name) \ virshCommandOptPoolBy(_ctl, _cmd, _optname, _name, \ - VSH_BYUUID|VSH_BYNAME) + VIRSH_BYUUID | VIRSH_BYNAME) extern const vshCmdDef storagePoolCmds[]; diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index e1fec56..db900c0 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -94,7 +94,7 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) return false; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; if (!(res = virSecretDefineXML(priv->conn, buffer, 0))) { @@ -333,7 +333,7 @@ cmdSecretUndefine(vshControl *ctl, const vshCmd *cmd) } static int -vshSecretSorter(const void *a, const void *b) +virshSecretSorter(const void *a, const void *b) { virSecretPtr *sa = (virSecretPtr *) a; virSecretPtr *sb = (virSecretPtr *) b; @@ -352,14 +352,14 @@ vshSecretSorter(const void *a, const void *b) return vshStrcasecmp(uuid_sa, uuid_sb); } -struct vshSecretList { +struct virshSecretList { virSecretPtr *secrets; size_t nsecrets; }; -typedef struct vshSecretList *vshSecretListPtr; +typedef struct virshSecretList *virshSecretListPtr; static void -vshSecretListFree(vshSecretListPtr list) +virshSecretListFree(virshSecretListPtr list) { size_t i; @@ -373,11 +373,11 @@ vshSecretListFree(vshSecretListPtr list) VIR_FREE(list); } -static vshSecretListPtr -vshSecretListCollect(vshControl *ctl, - unsigned int flags) +static virshSecretListPtr +virshSecretListCollect(vshControl *ctl, + unsigned int flags) { - vshSecretListPtr list = vshMalloc(ctl, sizeof(*list)); + virshSecretListPtr list = vshMalloc(ctl, sizeof(*list)); size_t i; int ret; virSecretPtr secret; @@ -447,7 +447,7 @@ vshSecretListCollect(vshControl *ctl, /* sort the list */ if (list->secrets && list->nsecrets) qsort(list->secrets, list->nsecrets, - sizeof(*list->secrets), vshSecretSorter); + sizeof(*list->secrets), virshSecretSorter); /* truncate the list for not found secret objects */ if (deleted) @@ -463,7 +463,7 @@ vshSecretListCollect(vshControl *ctl, } if (!success) { - vshSecretListFree(list); + virshSecretListFree(list); list = NULL; } @@ -507,7 +507,7 @@ static bool cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { size_t i; - vshSecretListPtr list = NULL; + virshSecretListPtr list = NULL; bool ret = false; unsigned int flags = 0; @@ -523,7 +523,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) if (vshCommandOptBool(cmd, "no-private")) flags |= VIR_CONNECT_LIST_SECRETS_NO_PRIVATE; - if (!(list = vshSecretListCollect(ctl, flags))) + if (!(list = virshSecretListCollect(ctl, flags))) return false; vshPrintExtra(ctl, " %-36s %s\n", _("UUID"), _("Usage")); @@ -554,7 +554,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ret = true; cleanup: - vshSecretListFree(list); + virshSecretListFree(list); return ret; } diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 839a322..3ab2104 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -207,7 +207,7 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) if (!from) { buffer = vshStrdup(ctl, "<domainsnapshot/>"); } else { - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) { + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshSaveLibvirtError(); goto cleanup; } @@ -227,7 +227,7 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) * "snapshot-create-as" command */ static int -vshParseSnapshotMemspec(vshControl *ctl, virBufferPtr buf, const char *str) +virshParseSnapshotMemspec(vshControl *ctl, virBufferPtr buf, const char *str) { int ret = -1; const char *snapshot = NULL; @@ -267,7 +267,7 @@ vshParseSnapshotMemspec(vshControl *ctl, virBufferPtr buf, const char *str) } static int -vshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str) +virshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str) { int ret = -1; const char *name = NULL; @@ -434,14 +434,14 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "memspec", &memspec) < 0) goto cleanup; - if (memspec && vshParseSnapshotMemspec(ctl, &buf, memspec) < 0) + if (memspec && virshParseSnapshotMemspec(ctl, &buf, memspec) < 0) goto cleanup; if (vshCommandOptBool(cmd, "diskspec")) { virBufferAddLit(&buf, "<disks>\n"); virBufferAdjustIndent(&buf, 2); while ((opt = vshCommandOptArgv(ctl, cmd, opt))) { - if (vshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0) + if (virshParseSnapshotDiskspec(ctl, &buf, opt->data) < 0) goto cleanup; } virBufferAdjustIndent(&buf, -2); @@ -478,9 +478,9 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) * present. On success, populate *SNAP and *NAME, before returning 0. * On failure, return -1 after issuing an error message. */ static int -vshLookupSnapshot(vshControl *ctl, const vshCmd *cmd, - const char *arg, bool exclusive, virDomainPtr dom, - virDomainSnapshotPtr *snap, const char **name) +virshLookupSnapshot(vshControl *ctl, const vshCmd *cmd, + const char *arg, bool exclusive, virDomainPtr dom, + virDomainSnapshotPtr *snap, const char **name) { bool current = vshCommandOptBool(cmd, "current"); const char *snapname = NULL; @@ -571,8 +571,8 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; - if (vshLookupSnapshot(ctl, cmd, "snapshotname", false, dom, - &snapshot, &name) < 0) + if (virshLookupSnapshot(ctl, cmd, "snapshotname", false, dom, + &snapshot, &name) < 0) goto cleanup; #define EDIT_GET_XML \ @@ -755,8 +755,8 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) * proven no parent exists), and -1 on failure with error reported * (such as no snapshot support or domain deleted in meantime). */ static int -vshGetSnapshotParent(vshControl *ctl, virDomainSnapshotPtr snapshot, - char **parent_name) +virshGetSnapshotParent(vshControl *ctl, virDomainSnapshotPtr snapshot, + char **parent_name) { virDomainSnapshotPtr parent = NULL; char *xml = NULL; @@ -816,8 +816,8 @@ vshGetSnapshotParent(vshControl *ctl, virDomainSnapshotPtr snapshot, * 1 if snapshot is okay (or if snapshot is already NULL), and -1 on * failure, with error already reported. */ static int -vshSnapshotFilter(vshControl *ctl, virDomainSnapshotPtr snapshot, - unsigned int flags) +virshSnapshotFilter(vshControl *ctl, virDomainSnapshotPtr snapshot, + unsigned int flags) { char *xml = NULL; xmlDocPtr xmldoc = NULL; @@ -921,8 +921,8 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd) if (dom == NULL) return false; - if (vshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, - &snapshot, &name) < 0) + if (virshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, + &snapshot, &name) < 0) goto cleanup; vshPrint(ctl, "%-15s %s\n", _("Name:"), name); @@ -1045,18 +1045,18 @@ cmdSnapshotInfo(vshControl *ctl, const vshCmd *cmd) } /* Helpers for collecting a list of snapshots. */ -struct vshSnap { +struct virshSnap { virDomainSnapshotPtr snap; char *parent; }; -struct vshSnapshotList { - struct vshSnap *snaps; +struct virshSnapshotList { + struct virshSnap *snaps; int nsnaps; }; -typedef struct vshSnapshotList *virshSnapshotListPtr; +typedef struct virshSnapshotList *virshSnapshotListPtr; static void -vshSnapshotListFree(virshSnapshotListPtr snaplist) +virshSnapshotListFree(virshSnapshotListPtr snaplist) { size_t i; @@ -1074,10 +1074,10 @@ vshSnapshotListFree(virshSnapshotListPtr snaplist) } static int -vshSnapSorter(const void *a, const void *b) +virshSnapSorter(const void *a, const void *b) { - const struct vshSnap *sa = a; - const struct vshSnap *sb = b; + const struct virshSnap *sa = a; + const struct virshSnap *sb = b; if (sa->snap && !sb->snap) return -1; @@ -1093,9 +1093,9 @@ vshSnapSorter(const void *a, const void *b) * given, the list is filtered. If TREE is specified, then all but * FROM or the roots will also have parent information. */ static virshSnapshotListPtr -vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom, - virDomainSnapshotPtr from, - unsigned int orig_flags, bool tree) +virshSnapshotListCollect(vshControl *ctl, virDomainPtr dom, + virDomainSnapshotPtr from, + unsigned int orig_flags, bool tree) { size_t i; char **names = NULL; @@ -1144,8 +1144,8 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom, VIR_FREE(snaps); if (tree) { for (i = 0; i < count; i++) { - if (vshGetSnapshotParent(ctl, snaplist->snaps[i].snap, - &snaplist->snaps[i].parent) < 0) + if (virshGetSnapshotParent(ctl, snaplist->snaps[i].snap, + &snaplist->snaps[i].parent) < 0) goto cleanup; } if (from) { @@ -1295,8 +1295,8 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom, if (tree) continue; } - if (vshGetSnapshotParent(ctl, snaplist->snaps[i].snap, - &snaplist->snaps[i].parent) < 0) + if (virshGetSnapshotParent(ctl, snaplist->snaps[i].snap, + &snaplist->snaps[i].parent) < 0) goto cleanup; if ((from && ((tree && !snaplist->snaps[i].parent) || (!descendants && @@ -1387,8 +1387,8 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom, if (!(orig_flags & VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION)) orig_flags |= VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION; for (i = 0; i < snaplist->nsnaps; i++) { - switch (vshSnapshotFilter(ctl, snaplist->snaps[i].snap, - orig_flags)) { + switch (virshSnapshotFilter(ctl, snaplist->snaps[i].snap, + orig_flags)) { case 1: break; case 0: @@ -1403,14 +1403,14 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom, } } qsort(snaplist->snaps, snaplist->nsnaps, sizeof(*snaplist->snaps), - vshSnapSorter); + virshSnapSorter); snaplist->nsnaps -= deleted; ret = snaplist; snaplist = NULL; cleanup: - vshSnapshotListFree(snaplist); + virshSnapshotListFree(snaplist); if (names && count > 0) for (i = 0; i < count; i++) VIR_FREE(names[i]); @@ -1592,10 +1592,10 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) return false; if ((from || current) && - vshLookupSnapshot(ctl, cmd, "from", true, dom, &start, &from_snap) < 0) + virshLookupSnapshot(ctl, cmd, "from", true, dom, &start, &from_snap) < 0) goto cleanup; - if (!(snaplist = vshSnapshotListCollect(ctl, dom, start, flags, tree))) + if (!(snaplist = virshSnapshotListCollect(ctl, dom, start, flags, tree))) goto cleanup; if (!tree && !name) { @@ -1614,8 +1614,8 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) if (tree) { for (i = 0; i < snaplist->nsnaps; i++) { if (!snaplist->snaps[i].parent && - virshTreePrint(ctl, virshSnapshotListLookup, snaplist, - snaplist->nsnaps, i) < 0) + vshTreePrint(ctl, virshSnapshotListLookup, snaplist, + snaplist->nsnaps, i) < 0) goto cleanup; } ret = true; @@ -1678,7 +1678,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) cleanup: /* this frees up memory from the last iteration of the loop */ - vshSnapshotListFree(snaplist); + virshSnapshotListFree(snaplist); VIR_FREE(parent_snap); VIR_FREE(state); if (start) @@ -1802,11 +1802,11 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd) if (dom == NULL) goto cleanup; - if (vshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, - &snapshot, &name) < 0) + if (virshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, + &snapshot, &name) < 0) goto cleanup; - if (vshGetSnapshotParent(ctl, snapshot, &parent) < 0) + if (virshGetSnapshotParent(ctl, snapshot, &parent) < 0) goto cleanup; if (!parent) { vshError(ctl, _("snapshot '%s' has no parent"), name); @@ -1895,8 +1895,8 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd) if (dom == NULL) goto cleanup; - if (vshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, - &snapshot, &name) < 0) + if (virshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, + &snapshot, &name) < 0) goto cleanup; result = virDomainRevertToSnapshot(snapshot, flags); @@ -1975,8 +1975,8 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd) if (dom == NULL) goto cleanup; - if (vshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, - &snapshot, &name) < 0) + if (virshLookupSnapshot(ctl, cmd, "snapshotname", true, dom, + &snapshot, &name) < 0) goto cleanup; if (vshCommandOptBool(cmd, "children")) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 11b54ce..7d76a06 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -53,7 +53,7 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, const char *n = NULL, *p = NULL; virshControlPtr priv = ctl->privData; - virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL); + virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL); if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0) return NULL; @@ -80,19 +80,19 @@ virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, *name = n; /* try it by name */ - if (pool && (flags & VSH_BYNAME)) { + if (pool && (flags & VIRSH_BYNAME)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as vol name\n", cmd->def->name, optname); vol = virStorageVolLookupByName(pool, n); } /* try it by key */ - if (!vol && (flags & VSH_BYUUID)) { + if (!vol && (flags & VIRSH_BYUUID)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as vol key\n", cmd->def->name, optname); vol = virStorageVolLookupByKey(priv->conn, n); } /* try it by path */ - if (!vol && (flags & VSH_BYUUID)) { + if (!vol && (flags & VIRSH_BYUUID)) { vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as vol path\n", cmd->def->name, optname); vol = virStorageVolLookupByPath(priv->conn, n); @@ -184,7 +184,7 @@ static const vshCmdOptDef opts_vol_create_as[] = { }; static int -vshVolSize(const char *data, unsigned long long *val) +virshVolSize(const char *data, unsigned long long *val) { char *end; if (virStrToLong_ull(data, &end, 10, val) < 0) @@ -217,13 +217,13 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0) goto cleanup; - if (vshVolSize(capacityStr, &capacity) < 0) { + if (virshVolSize(capacityStr, &capacity) < 0) { vshError(ctl, _("Malformed size %s"), capacityStr); goto cleanup; } if (vshCommandOptString(ctl, cmd, "allocation", &allocationStr) > 0 && - vshVolSize(allocationStr, &allocation) < 0) { + virshVolSize(allocationStr, &allocation) < 0) { vshError(ctl, _("Malformed size %s"), allocationStr); goto cleanup; } @@ -389,7 +389,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) goto cleanup; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) { + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshSaveLibvirtError(); goto cleanup; } @@ -478,7 +478,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) if (!(inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL))) goto cleanup; - if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) { + if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); goto cleanup; } @@ -506,7 +506,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) } static xmlChar * -vshMakeCloneXML(const char *origxml, const char *newname) +virshMakeCloneXML(const char *origxml, const char *newname) { xmlDocPtr doc = NULL; @@ -606,7 +606,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) if (!origxml) goto cleanup; - newxml = vshMakeCloneXML(origxml, name); + newxml = virshMakeCloneXML(origxml, name); if (!newxml) { vshPrint(ctl, "%s", _("Failed to allocate XML buffer")); goto cleanup; @@ -987,8 +987,8 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) } -VIR_ENUM_DECL(vshStorageVol) -VIR_ENUM_IMPL(vshStorageVol, +VIR_ENUM_DECL(virshStorageVol) +VIR_ENUM_IMPL(virshStorageVol, VIR_STORAGE_VOL_LAST, N_("file"), N_("block"), @@ -997,9 +997,9 @@ VIR_ENUM_IMPL(vshStorageVol, N_("netdir")) static const char * -vshVolumeTypeToString(int type) +virshVolumeTypeToString(int type) { - const char *str = vshStorageVolTypeToString(type); + const char *str = virshStorageVolTypeToString(type); return str ? _(str) : _("unknown"); } @@ -1047,12 +1047,12 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) const char *unit; vshPrint(ctl, "%-15s %s\n", _("Type:"), - vshVolumeTypeToString(info.type)); + virshVolumeTypeToString(info.type)); - val = virshPrettyCapacity(info.capacity, &unit); + val = vshPrettyCapacity(info.capacity, &unit); vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit); - val = virshPrettyCapacity(info.allocation, &unit); + val = vshPrettyCapacity(info.allocation, &unit); vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit); } else { ret = false; @@ -1142,7 +1142,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd) if (delta) flags |= VIR_STORAGE_VOL_RESIZE_DELTA; - if (vshVolSize(capacityStr, &capacity) < 0) { + if (virshVolSize(capacityStr, &capacity) < 0) { vshError(ctl, _("Malformed size %s"), capacityStr); goto cleanup; } @@ -1215,7 +1215,7 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd) } static int -vshStorageVolSorter(const void *a, const void *b) +virshStorageVolSorter(const void *a, const void *b) { virStorageVolPtr *va = (virStorageVolPtr *) a; virStorageVolPtr *vb = (virStorageVolPtr *) b; @@ -1319,7 +1319,7 @@ virshStorageVolListCollect(vshControl *ctl, finished: /* sort the list */ if (list->vols && list->nvols) - qsort(list->vols, list->nvols, sizeof(*list->vols), vshStorageVolSorter); + qsort(list->vols, list->nvols, sizeof(*list->vols), virshStorageVolSorter); if (deleted) VIR_SHRINK_N(list->vols, list->nvols, deleted); @@ -1423,14 +1423,14 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) /* Volume type */ volInfoTexts[i].type = vshStrdup(ctl, - vshVolumeTypeToString(volumeInfo.type)); + virshVolumeTypeToString(volumeInfo.type)); - val = virshPrettyCapacity(volumeInfo.capacity, &unit); + val = vshPrettyCapacity(volumeInfo.capacity, &unit); if (virAsprintf(&volInfoTexts[i].capacity, "%.2lf %s", val, unit) < 0) goto cleanup; - val = virshPrettyCapacity(volumeInfo.allocation, &unit); + val = vshPrettyCapacity(volumeInfo.allocation, &unit); if (virAsprintf(&volInfoTexts[i].allocation, "%.2lf %s", val, unit) < 0) goto cleanup; @@ -1610,7 +1610,7 @@ cmdVolName(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr vol; if (!(vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, - VSH_BYUUID))) + VIRSH_BYUUID))) return false; vshPrint(ctl, "%s\n", virStorageVolGetName(vol)); @@ -1653,7 +1653,7 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd) /* Use the supplied string to locate the volume */ if (!(vol = virshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, - VSH_BYUUID))) { + VIRSH_BYUUID))) { return false; } diff --git a/tools/virsh-volume.h b/tools/virsh-volume.h index be56928..e01ede4 100644 --- a/tools/virsh-volume.h +++ b/tools/virsh-volume.h @@ -36,7 +36,7 @@ virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, /* default is lookup by Name and UUID */ # define virshCommandOptVol(_ctl, _cmd, _optname, _pooloptname, _name) \ virshCommandOptVolBy(_ctl, _cmd, _optname, _pooloptname, _name, \ - VSH_BYUUID|VSH_BYNAME) + VIRSH_BYUUID | VIRSH_BYNAME) extern const vshCmdDef storageVolCmds[]; diff --git a/tools/virsh.c b/tools/virsh.c index fcbd553..97294c5 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -84,45 +84,6 @@ static char *progname; static const vshCmdGrp cmdGroups[]; static const vshClientHooks hooks; -double -virshPrettyCapacity(unsigned long long val, const char **unit) -{ - double limit = 1024; - - if (val < limit) { - *unit = "B"; - return val; - } - limit *= 1024; - if (val < limit) { - *unit = "KiB"; - return val / (limit / 1024); - } - limit *= 1024; - if (val < limit) { - *unit = "MiB"; - return val / (limit / 1024); - } - limit *= 1024; - if (val < limit) { - *unit = "GiB"; - return val / (limit / 1024); - } - limit *= 1024; - if (val < limit) { - *unit = "TiB"; - return val / (limit / 1024); - } - limit *= 1024; - if (val < limit) { - *unit = "PiB"; - return val / (limit / 1024); - } - limit *= 1024; - *unit = "EiB"; - return val / (limit / 1024); -} - /* * Detection of disconnections and automatic reconnection support */ @@ -301,94 +262,6 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd) return true; } - -#ifndef WIN32 -static void -virshPrintRaw(vshControl *ctl, ...) -{ - va_list ap; - char *key; - - va_start(ap, ctl); - while ((key = va_arg(ap, char *)) != NULL) - vshPrint(ctl, "%s\r\n", key); - va_end(ap); -} - -/** - * vshAskReedit: - * @msg: Question to ask user - * - * Ask user if he wants to return to previously - * edited file. - * - * Returns 'y' if he wants to - * 'n' if he doesn't want to - * 'i' if he wants to try defining it again while ignoring validation - * 'f' if he forcibly wants to - * -1 on error - * 0 otherwise - */ -int -virshAskReedit(vshControl *ctl, const char *msg, bool relax_avail) -{ - int c = -1; - - if (!isatty(STDIN_FILENO)) - return -1; - - vshReportError(ctl); - - if (vshTTYMakeRaw(ctl, false) < 0) - return -1; - - while (true) { - vshPrint(ctl, "\r%s %s %s: ", msg, _("Try again?"), - relax_avail ? "[y,n,i,f,?]" : "[y,n,f,?]"); - c = c_tolower(getchar()); - - if (c == '?') { - virshPrintRaw(ctl, - "", - _("y - yes, start editor again"), - _("n - no, throw away my changes"), - NULL); - - if (relax_avail) { - virshPrintRaw(ctl, - _("i - turn off validation and try to redefine " - "again"), - NULL); - } - - virshPrintRaw(ctl, - _("f - force, try to redefine again"), - _("? - print this help"), - NULL); - continue; - } else if (c == 'y' || c == 'n' || c == 'f' || - (relax_avail && c == 'i')) { - break; - } - } - - vshTTYRestore(ctl); - - vshPrint(ctl, "\r\n"); - return c; -} -#else /* WIN32 */ -int -virshAskReedit(vshControl *ctl, - const char *msg ATTRIBUTE_UNUSED, - bool relax_avail ATTRIBUTE_UNUSED) -{ - vshDebug(ctl, VSH_ERR_WARNING, "%s", _("This function is not " - "supported on WIN32 platform")); - return 0; -} -#endif /* WIN32 */ - int virshStreamSink(virStreamPtr st ATTRIBUTE_UNUSED, const char *bytes, size_t nbytes, void *opaque) { @@ -462,207 +335,6 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd) } } -/* Tree listing helpers. */ - -static int -virshTreePrintInternal(vshControl *ctl, - vshTreeLookup lookup, - void *opaque, - int num_devices, - int devid, - int lastdev, - bool root, - virBufferPtr indent) -{ - size_t i; - int nextlastdev = -1; - int ret = -1; - const char *dev = (lookup)(devid, false, opaque); - - if (virBufferError(indent)) - goto cleanup; - - /* Print this device, with indent if not at root */ - vshPrint(ctl, "%s%s%s\n", virBufferCurrentContent(indent), - root ? "" : "+- ", dev); - - /* Update indent to show '|' or ' ' for child devices */ - if (!root) { - virBufferAddChar(indent, devid == lastdev ? ' ' : '|'); - virBufferAddChar(indent, ' '); - if (virBufferError(indent)) - goto cleanup; - } - - /* Determine the index of the last child device */ - for (i = 0; i < num_devices; i++) { - const char *parent = (lookup)(i, true, opaque); - - if (parent && STREQ(parent, dev)) - nextlastdev = i; - } - - /* If there is a child device, then print another blank line */ - if (nextlastdev != -1) - vshPrint(ctl, "%s |\n", virBufferCurrentContent(indent)); - - /* Finally print all children */ - virBufferAddLit(indent, " "); - if (virBufferError(indent)) - goto cleanup; - for (i = 0; i < num_devices; i++) { - const char *parent = (lookup)(i, true, opaque); - - if (parent && STREQ(parent, dev) && - virshTreePrintInternal(ctl, lookup, opaque, - num_devices, i, nextlastdev, - false, indent) < 0) - goto cleanup; - } - virBufferTrim(indent, " ", -1); - - /* If there was no child device, and we're the last in - * a list of devices, then print another blank line */ - if (nextlastdev == -1 && devid == lastdev) - vshPrint(ctl, "%s\n", virBufferCurrentContent(indent)); - - if (!root) - virBufferTrim(indent, NULL, 2); - ret = 0; - cleanup: - return ret; -} - -int -virshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque, - int num_devices, int devid) -{ - int ret; - virBuffer indent = VIR_BUFFER_INITIALIZER; - - ret = virshTreePrintInternal(ctl, lookup, opaque, num_devices, - devid, devid, true, &indent); - if (ret < 0) - vshError(ctl, "%s", _("Failed to complete tree listing")); - virBufferFreeAndReset(&indent); - return ret; -} - -/* Common code for the edit / net-edit / pool-edit functions which follow. */ -char * -virshEditWriteToTempFile(vshControl *ctl, const char *doc) -{ - char *ret; - const char *tmpdir; - int fd; - char ebuf[1024]; - - tmpdir = virGetEnvBlockSUID("TMPDIR"); - if (!tmpdir) tmpdir = "/tmp"; - if (virAsprintf(&ret, "%s/virshXXXXXX.xml", tmpdir) < 0) { - vshError(ctl, "%s", _("out of memory")); - return NULL; - } - fd = mkostemps(ret, 4, O_CLOEXEC); - if (fd == -1) { - vshError(ctl, _("mkostemps: failed to create temporary file: %s"), - virStrerror(errno, ebuf, sizeof(ebuf))); - VIR_FREE(ret); - return NULL; - } - - if (safewrite(fd, doc, strlen(doc)) == -1) { - vshError(ctl, _("write: %s: failed to write to temporary file: %s"), - ret, virStrerror(errno, ebuf, sizeof(ebuf))); - VIR_FORCE_CLOSE(fd); - unlink(ret); - VIR_FREE(ret); - return NULL; - } - if (VIR_CLOSE(fd) < 0) { - vshError(ctl, _("close: %s: failed to write or close temporary file: %s"), - ret, virStrerror(errno, ebuf, sizeof(ebuf))); - unlink(ret); - VIR_FREE(ret); - return NULL; - } - - /* Temporary filename: caller frees. */ - return ret; -} - -/* Characters permitted in $EDITOR environment variable and temp filename. */ -#define ACCEPTED_CHARS \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/_.:@" - -int -virshEditFile(vshControl *ctl, const char *filename) -{ - const char *editor; - virCommandPtr cmd; - int ret = -1; - int outfd = STDOUT_FILENO; - int errfd = STDERR_FILENO; - - editor = virGetEnvBlockSUID("VISUAL"); - if (!editor) - editor = virGetEnvBlockSUID("EDITOR"); - if (!editor) - editor = DEFAULT_EDITOR; - - /* Check that filename doesn't contain shell meta-characters, and - * if it does, refuse to run. Follow the Unix conventions for - * EDITOR: the user can intentionally specify command options, so - * we don't protect any shell metacharacters there. Lots more - * than virsh will misbehave if EDITOR has bogus contents (which - * is why sudo scrubs it by default). Conversely, if the editor - * is safe, we can run it directly rather than wasting a shell. - */ - if (strspn(editor, ACCEPTED_CHARS) != strlen(editor)) { - if (strspn(filename, ACCEPTED_CHARS) != strlen(filename)) { - vshError(ctl, - _("%s: temporary filename contains shell meta or other " - "unacceptable characters (is $TMPDIR wrong?)"), - filename); - return -1; - } - cmd = virCommandNewArgList("sh", "-c", NULL); - virCommandAddArgFormat(cmd, "%s %s", editor, filename); - } else { - cmd = virCommandNewArgList(editor, filename, NULL); - } - - virCommandSetInputFD(cmd, STDIN_FILENO); - virCommandSetOutputFD(cmd, &outfd); - virCommandSetErrorFD(cmd, &errfd); - if (virCommandRunAsync(cmd, NULL) < 0 || - virCommandWait(cmd, NULL) < 0) { - vshReportError(ctl); - goto cleanup; - } - ret = 0; - - cleanup: - virCommandFree(cmd); - return ret; -} - -char * -virshEditReadBackFile(vshControl *ctl, const char *filename) -{ - char *ret; - char ebuf[1024]; - - if (virFileReadAll(filename, VIRSH_MAX_XML_FILE, &ret) == -1) { - vshError(ctl, - _("%s: failed to read temporary file: %s"), - filename, virStrerror(errno, ebuf, sizeof(ebuf))); - return NULL; - } - return ret; -} - - /* * "cd" command */ @@ -1021,8 +693,7 @@ virshDeinit(vshControl *ctl) { virshControlPtr priv = ctl->privData; - vshReadlineDeinit(ctl); - vshCloseLogFile(ctl); + vshDeinit(ctl); VIR_FREE(ctl->name); if (priv->conn) { int ret; @@ -1502,6 +1173,7 @@ main(int argc, char **argv) ctl->imode = true; /* default is interactive mode */ ctl->log_fd = -1; /* Initialize log file descriptor */ ctl->debug = VSH_DEBUG_DEFAULT; + ctl->hooks = &hooks; /* In order to distinguish default from setting to 0 */ ctl->keepalive_interval = -1; @@ -1556,7 +1228,7 @@ main(int argc, char **argv) if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"))) ctl->name = vshStrdup(ctl, defaultConn); - if (vshInit(ctl, &hooks, cmdGroups) < 0) + if (vshInit(ctl, cmdGroups, NULL) < 0) exit(EXIT_FAILURE); if (!virshParseArgv(ctl, argc, argv) || @@ -1578,11 +1250,6 @@ main(int argc, char **argv) " 'quit' to quit\n\n")); } - if (vshReadlineInit(ctl) < 0) { - virshDeinit(ctl); - exit(EXIT_FAILURE); - } - do { const char *prompt = virshCtl.readonly ? VIRSH_PROMPT_RO : VIRSH_PROMPT_RW; diff --git a/tools/virsh.h b/tools/virsh.h index d10ed66..6c4159a 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -38,8 +38,6 @@ # include "virthread.h" # include "vsh.h" -# define VIRSH_MAX_XML_FILE (10*1024*1024) - # define VIRSH_PROMPT_RW "virsh # " # define VIRSH_PROMPT_RO "virsh > " @@ -95,24 +93,19 @@ struct _virshCtrlData { virConnectPtr dconn; }; -virConnectPtr virshConnect(vshControl *ctl, const char *uri, bool readonly); +/* Filter flags for various vshCommandOpt*By() functions */ +typedef enum { + VIRSH_BYID = (1 << 1), + VIRSH_BYUUID = (1 << 2), + VIRSH_BYNAME = (1 << 3), + VIRSH_BYMAC = (1 << 4), +} virshLookupByFlags; +virConnectPtr virshConnect(vshControl *ctl, const char *uri, bool readonly); int virshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout); - -/* Given an index, return either the name of that device (non-NULL) or - * of its parent (NULL if a root). */ -typedef const char * (*vshTreeLookup)(int devid, bool parent, void *opaque); -int virshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque, - int num_devices, int devid); - int virshDomainState(vshControl *ctl, virDomainPtr dom, int *reason); -char *virshEditWriteToTempFile(vshControl *ctl, const char *doc); -int virshEditFile(vshControl *ctl, const char *filename); -char *virshEditReadBackFile(vshControl *ctl, const char *filename); -int virshAskReedit(vshControl *ctl, const char *msg, bool relax_avail); int virshStreamSink(virStreamPtr st, const char *bytes, size_t nbytes, - void *opaque); -double virshPrettyCapacity(unsigned long long val, const char **unit); + void *opaque); #endif /* VIRSH_H */ diff --git a/tools/vsh.c b/tools/vsh.c index 9b810c9..f4c342b 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2224,27 +2521,30 @@ vshReadlineInit(vshControl *ctl) * Work around ancient readline 4.1 (hello Mac OS X), * which declared it as 'char *' instead of 'const char *'. */ - rl_readline_name = (char *) "virsh"; + rl_readline_name = (char *) "virtshell"; /* Tell the completer that we want a crack first. */ rl_attempted_completion_function = vshReadlineCompletion; /* Limit the total size of the history buffer */ - if ((histsize_str = virGetEnvBlockSUID("VIRSH_HISTSIZE"))) { + if ((histsize_str = virGetEnvBlockSUID("VIRTSHELL_HISTSIZE"))) { if (virStrToLong_i(histsize_str, NULL, 10, &max_history) < 0) { - vshError(ctl, "%s", _("Bad $VIRSH_HISTSIZE value.")); + vshError(ctl, "%s", _("Bad $VIRTSHELL_HISTSIZE value.")); VIR_FREE(userdir); return -1; - } else if (max_history > VIRSH_HISTSIZE_MAX || max_history < 0) { - vshError(ctl, _("$VIRSH_HISTSIZE value should be between 0 and %d"), - VIRSH_HISTSIZE_MAX); + } else if (max_history > VIRTSHELL_HISTSIZE_MAX || max_history < 0) { + vshError(ctl, _("$VIRTSHELL_HISTSIZE value should be between 0 " + "and %d"), + VIRTSHELL_HISTSIZE_MAX); VIR_FREE(userdir); return -1; } } stifle_history(max_history); - /* Prepare to read/write history from/to the $XDG_CACHE_HOME/virsh/history file */ + /* Prepare to read/write history from/to the + * $XDG_CACHE_HOME/virtshell/history file + */ userdir = virGetUserCacheDirectory(); if (userdir == NULL) { @@ -2252,7 +2552,7 @@ vshReadlineInit(vshControl *ctl) return -1; } - if (virAsprintf(&ctl->historydir, "%s/virsh", userdir) < 0) { + if (virAsprintf(&ctl->historydir, "%s/virtshell", userdir) < 0) { vshError(ctl, "%s", _("Out of memory")); VIR_FREE(userdir); return -1;
These hunks ^^ add support for environment variable with prefix 'VIRTSHELL' and configuration getting from '.config/virtshell'. This might be viewed as a "feature", although it's not IMNSHO :) Don't get me wrong, I only think that different tools should not share history :) Also it will cause a regression when someone used VIRSH_HISTSIZE and it will now silently stop working for them. Also the rl_readline_name should be "virsh" for virsh. I think instead of these, you should use a parameter passed to the initialization that will be stored in the control structure that will tell you the intentional name of the binary (not the program name taken from argv[0]) and this could all be based on that. I seriously hope we're not getting any other issues because of this patch(set) because finding a problem in it in the future terrible, but splitting it now into multiple patches doesn't seem worth it to me. I would like another opinion, though. My opinion is that we should fix this one last thing I mentioned above and squash it in a patch we push this week since it's still early after a release. Martin
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list