[libvirt] [PATCH] lib: fix no zero arg check for iothread_id
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1251886
We do not allow delete an iothread which id is 0 in
virDomainDelIOThread, but allow it in virDomainAddIOThread,
Also we will output an error when parse an iothread which id
is 0.
Add a check for iothread_id in virDomainAddIOThread to fix
it.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
Is that okay to fix it in this place ?
src/libvirt-domain.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 837933f..8506942 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -7987,6 +7987,7 @@ virDomainAddIOThread(virDomainPtr domain,
virCheckDomainReturn(domain, -1);
virCheckReadOnlyGoto(domain->conn->flags, error);
+ virCheckNonZeroArgGoto(iothread_id, error);
conn = domain->conn;
--
1.8.3.1
9 years, 4 months
[libvirt] [PATCH v2] virt-shell: v2 diff patch to original series
by Erik Skultety
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
@@ -67,12 +67,56 @@
# define SA_SIGINFO 0
#endif
-static const vshClientHooks *hooks;
-static const vshCmdGrp *cmdGroups;
+/* NOTE: It would be much nicer to have these two as part of vshControl
+ * structure, unfortunately readline doesn't support passing opaque data
+ * and only relies on static data accessible from the user-side callback
+ */
+const vshCmdGrp *cmdGroups;
+const vshCmdDef *cmdSet;
/* Bypass header poison */
#undef strdup
+double
+vshPrettyCapacity(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);
+}
+
+
void *
_vshMalloc(vshControl *ctl, size_t size, const char *filename, int line)
{
@@ -194,7 +238,7 @@ vshErrorHandler(void *opaque ATTRIBUTE_UNUSED, virErrorPtr error)
{
virFreeError(last_error);
last_error = virSaveLastError();
- if (virGetEnvAllowSUID("VIRSH_DEBUG") != NULL)
+ if (virGetEnvAllowSUID("VSH_DEBUG") != NULL)
virDefaultErrorFunc(error);
}
@@ -454,8 +498,8 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required,
return -1;
}
-const vshCmdDef *
-vshCmddefSearch(const char *cmdname)
+static const vshCmdDef *
+vshCmdDefSearchGrp(const char *cmdname)
{
const vshCmdGrp *g;
const vshCmdDef *c;
@@ -470,6 +514,28 @@ vshCmddefSearch(const char *cmdname)
return NULL;
}
+static const vshCmdDef *
+vshCmdDefSearchSet(const char *cmdname)
+{
+ const vshCmdDef *s;
+
+ for (s = cmdSet; s->name; s++) {
+ if (STREQ(s->name, cmdname))
+ return s;
+ }
+
+ return NULL;
+}
+
+const vshCmdDef *
+vshCmddefSearch(const char *cmdname)
+{
+ if (cmdGroups)
+ return vshCmdDefSearchGrp(cmdname);
+ else
+ return vshCmdDefSearchSet(cmdname);
+}
+
const vshCmdGrp *
vshCmdGrpSearch(const char *grpname)
{
@@ -722,7 +788,7 @@ vshCommandOpt(const vshCmd *cmd, const char *name, vshCmdOpt **opt,
/**
* vshCommandOptInt:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -784,7 +850,7 @@ vshCommandOptUIntInternal(vshControl *ctl,
/**
* vshCommandOptUInt:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -801,7 +867,7 @@ vshCommandOptUInt(vshControl *ctl, const vshCmd *cmd,
/**
* vshCommandOptUIntWrap:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -845,7 +911,7 @@ vshCommandOptULInternal(vshControl *ctl,
/*
* vshCommandOptUL:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -862,7 +928,7 @@ vshCommandOptUL(vshControl *ctl, const vshCmd *cmd,
/**
* vshCommandOptULWrap:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -879,7 +945,7 @@ vshCommandOptULWrap(vshControl *ctl, const vshCmd *cmd,
/**
* vshCommandOptString:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -908,7 +974,7 @@ vshCommandOptString(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
/**
* vshCommandOptStringReq:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command structure
* @name option name
* @value result (updated to NULL or the option argument)
@@ -953,7 +1019,7 @@ vshCommandOptStringReq(vshControl *ctl,
/**
* vshCommandOptLongLong:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -1010,7 +1076,7 @@ vshCommandOptULongLongInternal(vshControl *ctl,
/**
* vshCommandOptULongLong:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -1027,7 +1093,7 @@ vshCommandOptULongLong(vshControl *ctl, const vshCmd *cmd,
/**
* vshCommandOptULongLongWrap:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -1044,7 +1110,7 @@ vshCommandOptULongLongWrap(vshControl *ctl, const vshCmd *cmd,
/**
* vshCommandOptScaledInt:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @name option name
* @value result
@@ -1100,7 +1166,7 @@ vshCommandOptBool(const vshCmd *cmd, const char *name)
/**
* vshCommandOptArgv:
- * @ctl virsh control structure
+ * @ctl virtshell control structure
* @cmd command reference
* @opt starting point for the search
*
@@ -1131,6 +1197,7 @@ vshCommandOptArgv(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd,
bool
vshCommandRun(vshControl *ctl, const vshCmd *cmd)
{
+ const vshClientHooks *hooks = ctl->hooks;
bool ret = true;
while (cmd) {
@@ -1802,7 +1869,7 @@ vshEventTimeout(int timer ATTRIBUTE_UNUSED,
/**
* vshEventStart:
- * @ctl virsh command struct
+ * @ctl vsh command struct
* @timeout_ms max wait time in milliseconds, or 0 for indefinite
*
* Set up a wait for a libvirt event. The wait can be canceled by
@@ -1842,7 +1909,7 @@ vshEventStart(vshControl *ctl, int timeout_ms)
/**
* vshEventDone:
- * @ctl virsh command struct
+ * @ctl vsh command struct
*
* Call this from an event callback to let the main thread quit
* blocking on further events.
@@ -1859,7 +1926,7 @@ vshEventDone(vshControl *ctl)
/**
* vshEventWait:
- * @ctl virsh command struct
+ * @ctl vsh command struct
*
* Call this in the main thread after calling vshEventStart() then
* registering for one or more events. This call will block until
@@ -1890,7 +1957,7 @@ vshEventWait(vshControl *ctl)
/**
* vshEventCleanup:
- * @ctl virsh command struct
+ * @ctl vsh control struct
*
* Call at the end of any function that has used vshEventStart(), to
* tear down any remaining SIGINT or timeout handlers.
@@ -1907,65 +1974,6 @@ vshEventCleanup(vshControl *ctl)
virEventUpdateTimeout(ctl->eventTimerId, -1);
}
-
-/*
- * Initialize debug settings.
- */
-void
-vshInitDebug(vshControl *ctl)
-{
- const char *debugEnv;
-
- if (ctl->debug == VSH_DEBUG_DEFAULT) {
- /* log level not set from commandline, check env variable */
- debugEnv = virGetEnvAllowSUID("VIRSH_DEBUG");
- if (debugEnv) {
- int debug;
- if (virStrToLong_i(debugEnv, NULL, 10, &debug) < 0 ||
- debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) {
- vshError(ctl, "%s",
- _("VIRSH_DEBUG not set with a valid numeric value"));
- } else {
- ctl->debug = debug;
- }
- }
- }
-
- if (ctl->logfile == NULL) {
- /* log file not set from cmdline */
- debugEnv = virGetEnvBlockSUID("VIRSH_LOG_FILE");
- if (debugEnv && *debugEnv) {
- ctl->logfile = vshStrdup(ctl, debugEnv);
- vshOpenLogFile(ctl);
- }
- }
-}
-
-
-/*
- * Initialize global data
- */
-int
-vshInit(vshControl *ctl,
- const vshClientHooks *clhooks,
- const vshCmdGrp *clgrps)
-{
- if (!clhooks || !clhooks->connHandler) {
- vshError(ctl, "%s", _("client hooks must not be NULL"));
- return -1;
- }
-
- if (!clgrps) {
- vshError(ctl, "%s", _("command groups must not be NULL"));
- return -1;
- }
-
- hooks = clhooks;
- cmdGroups = clgrps;
- vshInitDebug(ctl);
- return 0;
-}
-
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
/**
@@ -2092,6 +2100,295 @@ vshCloseLogFile(vshControl *ctl)
}
}
+#ifndef WIN32
+static void
+vshPrintRaw(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
+vshAskReedit(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 == '?') {
+ vshPrintRaw(ctl,
+ "",
+ _("y - yes, start editor again"),
+ _("n - no, throw away my changes"),
+ NULL);
+
+ if (relax_avail) {
+ vshPrintRaw(ctl,
+ _("i - turn off validation and try to redefine "
+ "again"),
+ NULL);
+ }
+
+ vshPrintRaw(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
+vshAskReedit(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 */
+
+
+/* Common code for the edit / net-edit / pool-edit functions which follow. */
+char *
+vshEditWriteToTempFile(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
+vshEditFile(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 *
+vshEditReadBackFile(vshControl *ctl, const char *filename)
+{
+ char *ret;
+ char ebuf[1024];
+
+ if (virFileReadAll(filename, VSH_MAX_XML_FILE, &ret) == -1) {
+ vshError(ctl,
+ _("%s: failed to read temporary file: %s"),
+ filename, virStrerror(errno, ebuf, sizeof(ebuf)));
+ return NULL;
+ }
+ return ret;
+}
+
+
+/* Tree listing helpers. */
+
+static int
+vshTreePrintInternal(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) &&
+ vshTreePrintInternal(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
+vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
+ int num_devices, int devid)
+{
+ int ret;
+ virBuffer indent = VIR_BUFFER_INITIALIZER;
+
+ ret = vshTreePrintInternal(ctl, lookup, opaque, num_devices,
+ devid, devid, true, &indent);
+ if (ret < 0)
+ vshError(ctl, "%s", _("Failed to complete tree listing"));
+ virBufferFreeAndReset(&indent);
+ return ret;
+}
+
#if WITH_READLINE
/* -----------------
@@ -2211,9 +2508,9 @@ vshReadlineCompletion(const char *text, int start,
return matches;
}
-# define VIRSH_HISTSIZE_MAX 500000
+# define VIRTSHELL_HISTSIZE_MAX 500000
-int
+static int
vshReadlineInit(vshControl *ctl)
{
char *userdir = NULL;
@@ -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;
@@ -2271,7 +2571,7 @@ vshReadlineInit(vshControl *ctl)
return 0;
}
-void
+static void
vshReadlineDeinit(vshControl *ctl)
{
if (ctl->historyfile != NULL) {
@@ -2297,14 +2597,14 @@ vshReadline(vshControl *ctl ATTRIBUTE_UNUSED, const char *prompt)
#else /* !WITH_READLINE */
-int
+static int
vshReadlineInit(vshControl *ctl ATTRIBUTE_UNUSED)
{
/* empty */
return 0;
}
-void
+static void
vshReadlineDeinit(vshControl *ctl ATTRIBUTE_UNUSED)
{
/* empty */
@@ -2330,3 +2630,76 @@ vshReadline(vshControl *ctl, const char *prompt)
}
#endif /* !WITH_READLINE */
+
+/*
+ * Initialize debug settings.
+ */
+void
+vshInitDebug(vshControl *ctl)
+{
+ const char *debugEnv;
+
+ if (ctl->debug == VSH_DEBUG_DEFAULT) {
+ /* log level not set from commandline, check env variable */
+ debugEnv = virGetEnvAllowSUID("VSH_DEBUG");
+ if (debugEnv) {
+ int debug;
+ if (virStrToLong_i(debugEnv, NULL, 10, &debug) < 0 ||
+ debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR) {
+ vshError(ctl, "%s",
+ _("VSH_DEBUG not set with a valid numeric value"));
+ } else {
+ ctl->debug = debug;
+ }
+ }
+ }
+
+ if (ctl->logfile == NULL) {
+ /* log file not set from cmdline */
+ debugEnv = virGetEnvBlockSUID("VSH_LOG_FILE");
+ if (debugEnv && *debugEnv) {
+ ctl->logfile = vshStrdup(ctl, debugEnv);
+ vshOpenLogFile(ctl);
+ }
+ }
+}
+
+
+/*
+ * Initialize global data
+ */
+int
+vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set)
+{
+ int ret = -1;
+
+ if (!ctl->hooks) {
+ vshError(ctl, "%s", _("client hooks cannot be NULL"));
+ goto error;
+ }
+
+ if (!groups && !set) {
+ vshError(ctl, "%s", _("command groups and command set "
+ "cannot both be NULL"));
+ goto error;
+ }
+
+ cmdGroups = groups;
+ cmdSet = set;
+ vshInitDebug(ctl);
+
+ if (ctl->imode && vshReadlineInit(ctl) < 0)
+ goto error;
+
+ ret = 0;
+ error:
+ return ret;
+}
+
+void
+vshDeinit(vshControl *ctl)
+{
+ if (ctl->imode)
+ vshReadlineDeinit(ctl);
+ vshCloseLogFile(ctl);
+}
diff --git a/tools/vsh.h b/tools/vsh.h
index 1ad0287..66c9c3b 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -40,7 +40,7 @@
# define VIR_FROM_THIS VIR_FROM_NONE
# define GETTIMEOFDAY(T) gettimeofday(T, NULL)
-
+# define VSH_MAX_XML_FILE (10*1024*1024)
# define VSH_MATCH(FLAG) (flags & (FLAG))
/**
@@ -221,6 +221,8 @@ struct _vshControl {
struct termios termattr; /* settings of the tty terminal */
# endif
bool istty; /* is the terminal a tty */
+
+ const vshClientHooks *hooks;/* mandatory client specific hooks */
void *privData; /* client specific data */
};
@@ -294,19 +296,10 @@ const vshCmdOpt *vshCommandOptArgv(vshControl *ctl, const vshCmd *cmd,
const vshCmdOpt *opt);
bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv);
-/* Filter flags for various vshCommandOpt*By() functions */
-typedef enum {
- VSH_BYID = (1 << 1),
- VSH_BYUUID = (1 << 2),
- VSH_BYNAME = (1 << 3),
- VSH_BYMAC = (1 << 4),
-} vshLookupByFlags;
-
void vshPrintExtra(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3);
-int vshInit(vshControl *ctl, const vshClientHooks *clhooks,
- const vshCmdGrp *clgrps)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+int vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set);
+void vshDeinit(vshControl *ctl);
void vshInitDebug(vshControl *ctl);
void vshDebug(vshControl *ctl, int level, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(3, 4);
@@ -324,8 +317,15 @@ virTypedParameterPtr vshFindTypedParamByName(const char *name,
char *vshGetTypedParamValue(vshControl *ctl, virTypedParameterPtr item)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+double vshPrettyCapacity(unsigned long long val, const char **unit);
int vshStringToArray(const char *str, char ***array);
+/* 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 vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
+ int num_devices, int devid);
+
/* error handling */
extern virErrorPtr last_error;
void vshErrorHandler(void *opaque, virErrorPtr error);
@@ -333,6 +333,12 @@ void vshReportError(vshControl *ctl);
void vshResetLibvirtError(void);
void vshSaveLibvirtError(void);
+/* file handling */
+char *vshEditWriteToTempFile(vshControl *ctl, const char *doc);
+int vshEditFile(vshControl *ctl, const char *filename);
+char *vshEditReadBackFile(vshControl *ctl, const char *filename);
+int vshAskReedit(vshControl *ctl, const char *msg, bool relax_avail);
+
/* terminal modifications */
bool vshTTYIsInterruptCharacter(vshControl *ctl, const char chr);
int vshTTYDisableInterrupt(vshControl *ctl);
@@ -355,8 +361,6 @@ int vshEventWait(vshControl *ctl);
/* readline */
char * vshReadline(vshControl *ctl, const char *prompt);
-int vshReadlineInit(vshControl *ctl);
-void vshReadlineDeinit(vshControl *ctl);
/* allocation wrappers */
void *_vshMalloc(vshControl *ctl, size_t sz, const char *filename, int line);
--
1.9.3
9 years, 4 months
[libvirt] [frankschreuder@outlook.com: Fwd: Reproducible live disk detach bug]
by Richard W.M. Jones
Forwarding from Frank Schreuder who was having some issues
sending this to the mailing list.
----- Begin forwarded message -----
> Subject: Reproducible live disk detach bug
>
> Hey guys,
>
> I am currently running into a reproducible libvirt bug when I detach a
> disk from a running VM using libvirt 1.2.18 and qemu 2.3.0.
>
> I can attach a disk to a running VM without any problems.
> During the attach operation I don't create a disk alias name, which
> results in libvirt generating an unique alias.
> Using virsh dumpxml I get the following output(snippet):
>
> <disk type='file' device='disk'>
> <driver name='qemu' type='raw' cache='none'/>
> <source file='/var/local/mnt/test-storage/test-storage.raw'/>
> <backingStore/>
> <target dev='vde' bus='virtio'/>
> <iotune>
> <read_bytes_sec>94371840</read_bytes_sec>
> <write_bytes_sec>31457280</write_bytes_sec>
> <read_iops_sec>1000</read_iops_sec>
> <write_iops_sec>200</write_iops_sec>
> </iotune>
> <alias name='virtio-disk4'/>
> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
> </disk>
>
> As you can see, libvirt generates 'virtio-disk4' as an alias. But as
> soon as I try to detach the disk from the running VM, I will receive the
> following two errors in my libvirt log:
>
> 2015-08-06 10:48:59.943+0000: 11657: warning :
> qemuMonitorJSONHandleDeviceDeleted:939 : missing device in device
> deleted event
> 2015-08-06 10:48:59.945+0000: 11662: error :
> qemuMonitorTextDriveDel:2594 : operation failed: deleting
> drive-virtio-disk4 drive failed: 2015-08-06T10:48:59.945058Z Device
> 'drive-virtio-disk4' not found
>
> Apparently libvirt tries to detach the disk with a drive- prefix, which
> doesn't exist? The drive seems to detach correctly though.
>
> I hope somebody with more extensive knowledge about libvirt can help me
> solve this issue. If more information is needed, feel free to contact me.
>
> Thanks,
> Frank
----- End forwarded message -----
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
9 years, 4 months
[libvirt] [PATCHv3 00/13] Add new PCIe controllers
by Laine Stump
Since the first 3 patches of V2 were ACKed and uncontroversial, I
fixed the small problems pointed out in the reviews and pushed
them. Thus, Patches 01-13 here correspond to Patches 04-17 in V2.
Most of these patches were already ACKed in V2 (pending my making
small fixes pointed out in review), but the main things that need
review are:
1) changing of model name from a char* to an enum in Patch 01, and
corresponding blowback in patches 02, 07, 10, and 13
2) range checking of chassisNr in Patch 03 and chassis+port in patch
06.
3) check for duplicate <model> in patch 01, and duplicate <target> in
patch 03.
I did add one new negative test, and reworded some documentation, but I'm
about to go mostly offline for 10 days, and would rather not have
these patches bitrotting during that time if they are okay other than
that. (also, I see both of those tasks as having no practical end, but
do give my word to add more to both in later followups).
If by chance everything is ACKed before DV freezes for RC1, but after
I'm already offline (which will happen Sunday morning U.S. east coast
time), I would appreciate if the reviewer could push the patches so
they'll get the RC testing and be in the 1.2.18 release. (If not, I'll
take care of it when I return).
P.S. I ran "git rebase -i master -x "make -j8 check && make -j8
syntax-check" before sending.
Laine Stump (13):
conf: add new <model> subelement with name attribute to <controller>
qemu: implement <model> subelement to <controller>
conf: add new <target> subelement with chassisNr attribute to
<controller>
qemu: implement <target chassisNr='n'/> subelement/attribute of
<controller>
qemu: add capabilities bit for device ioh3420
conf: new pci controller model "pcie-root-port"
qemu: support new pci controller model "pcie-root-port"
qemu: add capabilities bit for device x3130-upstream
conf: new pci controller model "pcie-switch-upstream-port"
qemu: support new pci controller model "pcie-switch-upstream-port"
qemu: add capabilities bit for device xio3130-downstream
conf: new pcie-controller model "pcie-switch-downstream-port"
qemu: support new pci controller model "pcie-switch-downstream-port"
docs/formatdomain.html.in | 90 +++++++-
docs/schemas/domaincommon.rng | 42 ++++
src/conf/domain_addr.c | 32 ++-
src/conf/domain_addr.h | 12 +-
src/conf/domain_conf.c | 162 +++++++++++++-
src/conf/domain_conf.h | 34 +++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 8 +-
src/qemu/qemu_capabilities.h | 5 +-
src/qemu/qemu_command.c | 238 ++++++++++++++++++++-
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 3 +
tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 3 +
tests/qemuhelptest.c | 10 +-
.../qemuxml2argv-pcie-root-port-too-many.xml | 60 ++++++
.../qemuxml2argv-pcie-root-port.args | 10 +
.../qemuxml2argv-pcie-root-port.xml | 36 ++++
.../qemuxml2argv-pcie-switch-downstream-port.args | 18 ++
.../qemuxml2argv-pcie-switch-downstream-port.xml | 44 ++++
.../qemuxml2argv-pcie-switch-upstream-port.args | 12 ++
.../qemuxml2argv-pcie-switch-upstream-port.xml | 37 ++++
tests/qemuxml2argvdata/qemuxml2argv-q35.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-q35.xml | 9 +-
tests/qemuxml2argvtest.c | 33 +++
tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml | 9 +-
tests/qemuxml2xmltest.c | 4 +
30 files changed, 909 insertions(+), 21 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-too-many.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-downstream-port.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-downstream-port.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-switch-upstream-port.xml
--
2.1.0
9 years, 4 months
[libvirt] [PATCH] virNetDevBandwidthParseRate: Reject negative values
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1022292
The following XML really does not make any sense:
<inbound average="-1" burst="-2" peak="-3" floor="-4"/>
There can't be a negative packet rate. Well, so far we haven't
assigned any meaning to it. So reject it unless users harm themselves,
because otherwise we turn the negative numbers into really big values.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/netdev_bandwidth_conf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index fdd5b7f..8824332 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -50,7 +50,7 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
floor = virXMLPropString(node, "floor");
if (average) {
- if (virStrToLong_ull(average, NULL, 10, &rate->average) < 0) {
+ if (virStrToLong_ullp(average, NULL, 10, &rate->average) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("could not convert bandwidth average value '%s'"),
average);
@@ -68,21 +68,21 @@ virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
goto cleanup;
}
- if (peak && virStrToLong_ull(peak, NULL, 10, &rate->peak) < 0) {
+ if (peak && virStrToLong_ullp(peak, NULL, 10, &rate->peak) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("could not convert bandwidth peak value '%s'"),
peak);
goto cleanup;
}
- if (burst && virStrToLong_ull(burst, NULL, 10, &rate->burst) < 0) {
+ if (burst && virStrToLong_ullp(burst, NULL, 10, &rate->burst) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("could not convert bandwidth burst value '%s'"),
burst);
goto cleanup;
}
- if (floor && virStrToLong_ull(floor, NULL, 10, &rate->floor) < 0) {
+ if (floor && virStrToLong_ullp(floor, NULL, 10, &rate->floor) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("could not convert bandwidth floor value '%s'"),
floor);
--
2.4.6
9 years, 4 months
[libvirt] [PATCH v3] rpc: Remove keepalive_required option
by Martin Kletzander
Since its introduction in 2011 (particularly in commit f4324e329275),
the option doesn't work. It just effectively disables all incoming
connections. That's because the client private data that contain the
'keepalive_supported' boolean, are initialized to zeroes so the bool is
false and the only other place where the bool is used is when checking
whether the client supports keepalive. Thus, according to the server,
no client supports keepalive.
Removing this instead of fixing it is better because a) apparently
nobody ever tried it since 2011 (4 years without one month) and b) we
cannot know whether the client supports keepalive until we get a ping or
pong keepalive packet. And that won't happen untile after we dispatched
the ConnectOpen call.
Another two reasons would be c) the keepalive_required was tracked on
the server level, but keepalive_supported was in private data of the
client as well as the check that was made in the remote layer, thus
making all other instances of virNetServer miss this feature unless they
all implemented it for themselves and d) we can always add it back in
case there is a request and a use-case for it.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v3:
- Kept the config option in place the same way we did with
log_buffer_size
- Moved the deprecated options together
v2:
- Added a new daemontest file with current input/output.
daemon/libvirtd-config.c | 4 -
daemon/libvirtd-config.h | 2 -
daemon/libvirtd.c | 2 -
daemon/libvirtd.conf | 9 +-
daemon/libvirtd.h | 1 -
daemon/remote.c | 8 +-
daemon/test_libvirtd.aug.in | 2 +-
src/libvirt_remote.syms | 1 -
src/locking/lock_daemon.c | 2 +-
src/lxc/lxc_controller.c | 2 +-
src/rpc/virnetserver.c | 25 +----
src/rpc/virnetserver.h | 3 -
tests/libvirtdconftest.c | 4 +-
.../input-data-no-keepalive-required.json | 124 +++++++++++++++++++++
.../virnetdaemondata/output-data-admin-nomdns.json | 2 -
.../virnetdaemondata/output-data-anon-clients.json | 1 -
.../output-data-initial-nomdns.json | 1 -
tests/virnetdaemondata/output-data-initial.json | 1 -
.../output-data-no-keepalive-required.json | 124 +++++++++++++++++++++
tests/virnetdaemontest.c | 2 +-
20 files changed, 262 insertions(+), 58 deletions(-)
create mode 100644 tests/virnetdaemondata/input-data-no-keepalive-required.json
create mode 100644 tests/virnetdaemondata/output-data-no-keepalive-required.json
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 10dcc423d2db..c31c8b2e9ab5 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -292,7 +292,6 @@ daemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
data->keepalive_interval = 5;
data->keepalive_count = 5;
- data->keepalive_required = 0;
data->admin_min_workers = 5;
data->admin_max_workers = 20;
@@ -302,7 +301,6 @@ daemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
data->admin_keepalive_interval = 5;
data->admin_keepalive_count = 5;
- data->admin_keepalive_required = 0;
localhost = virGetHostname();
if (localhost == NULL) {
@@ -471,11 +469,9 @@ daemonConfigLoadOptions(struct daemonConfig *data,
GET_CONF_INT(conf, filename, keepalive_interval);
GET_CONF_UINT(conf, filename, keepalive_count);
- GET_CONF_UINT(conf, filename, keepalive_required);
GET_CONF_INT(conf, filename, admin_keepalive_interval);
GET_CONF_UINT(conf, filename, admin_keepalive_count);
- GET_CONF_UINT(conf, filename, admin_keepalive_required);
return 0;
diff --git a/daemon/libvirtd-config.h b/daemon/libvirtd-config.h
index 9cdae1a0cb59..3e1971d67f05 100644
--- a/daemon/libvirtd-config.h
+++ b/daemon/libvirtd-config.h
@@ -81,7 +81,6 @@ struct daemonConfig {
int keepalive_interval;
unsigned int keepalive_count;
- int keepalive_required;
int admin_min_workers;
int admin_max_workers;
@@ -91,7 +90,6 @@ struct daemonConfig {
int admin_keepalive_interval;
unsigned int admin_keepalive_count;
- int admin_keepalive_required;
};
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 71db4a042c7f..250094bd21dd 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1389,7 +1389,6 @@ int main(int argc, char **argv) {
config->max_anonymous_clients,
config->keepalive_interval,
config->keepalive_count,
- !!config->keepalive_required,
config->mdns_adv ? config->mdns_name : NULL,
remoteClientInitHook,
NULL,
@@ -1464,7 +1463,6 @@ int main(int argc, char **argv) {
0,
config->admin_keepalive_interval,
config->admin_keepalive_count,
- !!config->admin_keepalive_required,
NULL,
remoteAdmClientInitHook,
NULL,
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
index ac06cdd79103..514e6e4813bd 100644
--- a/daemon/libvirtd.conf
+++ b/daemon/libvirtd.conf
@@ -440,14 +440,15 @@
#
#keepalive_interval = 5
#keepalive_count = 5
+
#
-# If set to 1, libvirtd will refuse to talk to clients that do not
-# support keepalive protocol. Defaults to 0.
+# These configuration options are no longer used. There is no way to
+# restrict such clients from connecting since they first need to
+# connect in order to ask for keepalive.
#
#keepalive_required = 1
+#admin_keepalive_required = 1
# Keepalive settings for the admin interface
#admin_keepalive_interval = 5
#admin_keepalive_count = 5
-#
-#admin_keepalive_required = 1
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index 8c1a904893ab..efd4823ae18e 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -72,7 +72,6 @@ struct daemonClientPrivate {
virConnectPtr conn;
daemonClientStreamPtr streams;
- bool keepalive_supported;
};
/* Separate private data for admin connection */
diff --git a/daemon/remote.c b/daemon/remote.c
index e9e2dcae80e0..3a3eb0913088 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1290,7 +1290,7 @@ void *remoteClientInitHook(virNetServerClientPtr client,
/*----- Functions. -----*/
static int
-remoteDispatchConnectOpen(virNetServerPtr server,
+remoteDispatchConnectOpen(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
@@ -1309,12 +1309,6 @@ remoteDispatchConnectOpen(virNetServerPtr server,
goto cleanup;
}
- if (virNetServerKeepAliveRequired(server) && !priv->keepalive_supported) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("keepalive support is required to connect"));
- goto cleanup;
- }
-
name = args->name ? *args->name : NULL;
/* If this connection arrived on a readonly socket, force
diff --git a/daemon/test_libvirtd.aug.in b/daemon/test_libvirtd.aug.in
index 4921cbfb86b3..b0cb7eb14920 100644
--- a/daemon/test_libvirtd.aug.in
+++ b/daemon/test_libvirtd.aug.in
@@ -58,6 +58,6 @@ module Test_libvirtd =
{ "keepalive_interval" = "5" }
{ "keepalive_count" = "5" }
{ "keepalive_required" = "1" }
+ { "admin_keepalive_required" = "1" }
{ "admin_keepalive_interval" = "5" }
{ "admin_keepalive_count" = "5" }
- { "admin_keepalive_required" = "1" }
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 6bfdcfa819bf..90a453c8be9c 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -101,7 +101,6 @@ virNetServerAddProgram;
virNetServerAddService;
virNetServerClose;
virNetServerHasClients;
-virNetServerKeepAliveRequired;
virNetServerNew;
virNetServerNewPostExecRestart;
virNetServerPreExecRestart;
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index ecbe03a4c154..c03502459acd 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -151,7 +151,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged)
if (!(lockd->srv = virNetServerNew(1, 1, 0, config->max_clients,
config->max_clients, -1, 0,
- false, NULL,
+ NULL,
virLockDaemonClientNew,
virLockDaemonClientPreExecRestart,
virLockDaemonClientFree,
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 110a55662be0..48a3597ed274 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -925,7 +925,7 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
return -1;
if (!(srv = virNetServerNew(0, 0, 0, 1,
- 0, -1, 0, false,
+ 0, -1, 0,
NULL,
virLXCControllerClientPrivateNew,
NULL,
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 60a9714f6096..80b5588bf3c9 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -69,7 +69,6 @@ struct _virNetServer {
int keepaliveInterval;
unsigned int keepaliveCount;
- bool keepaliveRequired;
#ifdef WITH_GNUTLS
virNetTLSContextPtr tls;
@@ -312,7 +311,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
size_t max_anonymous_clients,
int keepaliveInterval,
unsigned int keepaliveCount,
- bool keepaliveRequired,
const char *mdnsGroupName,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivPreExecRestart clientPrivPreExecRestart,
@@ -338,7 +336,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
srv->nclients_unauth_max = max_anonymous_clients;
srv->keepaliveInterval = keepaliveInterval;
srv->keepaliveCount = keepaliveCount;
- srv->keepaliveRequired = keepaliveRequired;
srv->clientPrivNew = clientPrivNew;
srv->clientPrivPreExecRestart = clientPrivPreExecRestart;
srv->clientPrivFree = clientPrivFree;
@@ -380,7 +377,6 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
unsigned int max_anonymous_clients;
unsigned int keepaliveInterval;
unsigned int keepaliveCount;
- bool keepaliveRequired;
const char *mdnsGroupName = NULL;
if (virJSONValueObjectGetNumberUint(object, "min_workers", &min_workers) < 0) {
@@ -423,11 +419,6 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
_("Missing keepaliveCount data in JSON document"));
goto error;
}
- if (virJSONValueObjectGetBoolean(object, "keepaliveRequired", &keepaliveRequired) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Missing keepaliveRequired data in JSON document"));
- goto error;
- }
if (virJSONValueObjectHasKey(object, "mdnsGroupName") &&
(!(mdnsGroupName = virJSONValueObjectGetString(object, "mdnsGroupName")))) {
@@ -440,7 +431,7 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
priority_workers, max_clients,
max_anonymous_clients,
keepaliveInterval, keepaliveCount,
- keepaliveRequired, mdnsGroupName,
+ mdnsGroupName,
clientPrivNew, clientPrivPreExecRestart,
clientPrivFree, clientPrivOpaque)))
goto error;
@@ -573,11 +564,6 @@ virJSONValuePtr virNetServerPreExecRestart(virNetServerPtr srv)
_("Cannot set keepaliveCount data in JSON document"));
goto error;
}
- if (virJSONValueObjectAppendBoolean(object, "keepaliveRequired", srv->keepaliveRequired) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Cannot set keepaliveRequired data in JSON document"));
- goto error;
- }
if (srv->mdnsGroupName &&
virJSONValueObjectAppendString(object, "mdnsGroupName", srv->mdnsGroupName) < 0) {
@@ -786,15 +772,6 @@ void virNetServerClose(virNetServerPtr srv)
virObjectUnlock(srv);
}
-bool virNetServerKeepAliveRequired(virNetServerPtr srv)
-{
- bool required;
- virObjectLock(srv);
- required = srv->keepaliveRequired;
- virObjectUnlock(srv);
- return required;
-}
-
static inline size_t
virNetServerTrackPendingAuthLocked(virNetServerPtr srv)
{
diff --git a/src/rpc/virnetserver.h b/src/rpc/virnetserver.h
index 0e16e8fb1bf0..89d8db9b9ee4 100644
--- a/src/rpc/virnetserver.h
+++ b/src/rpc/virnetserver.h
@@ -41,7 +41,6 @@ virNetServerPtr virNetServerNew(size_t min_workers,
size_t max_anonymous_clients,
int keepaliveInterval,
unsigned int keepaliveCount,
- bool keepaliveRequired,
const char *mdnsGroupName,
virNetServerClientPrivNew clientPrivNew,
virNetServerClientPrivPreExecRestart clientPrivPreExecRestart,
@@ -74,8 +73,6 @@ int virNetServerSetTLSContext(virNetServerPtr srv,
virNetTLSContextPtr tls);
# endif
-bool virNetServerKeepAliveRequired(virNetServerPtr srv);
-
size_t virNetServerTrackPendingAuth(virNetServerPtr srv);
size_t virNetServerTrackCompletedAuth(virNetServerPtr srv);
diff --git a/tests/libvirtdconftest.c b/tests/libvirtdconftest.c
index d589d51cef30..61d861db1d1c 100644
--- a/tests/libvirtdconftest.c
+++ b/tests/libvirtdconftest.c
@@ -227,7 +227,9 @@ mymain(void)
for (i = 0; params[i] != 0; i++) {
const struct testCorruptData data = { params, filedata, filename, i };
/* Skip now ignored config param */
- if (STRPREFIX(filedata + params[i], "log_buffer_size"))
+ if (STRPREFIX(filedata + params[i], "log_buffer_size") ||
+ STRPREFIX(filedata + params[i], "keepalive_required") ||
+ STRPREFIX(filedata + params[i], "admin_keepalive_required"))
continue;
if (virtTestRun("Test corruption", testCorrupt, &data) < 0)
ret = -1;
diff --git a/tests/virnetdaemondata/input-data-no-keepalive-required.json b/tests/virnetdaemondata/input-data-no-keepalive-required.json
new file mode 100644
index 000000000000..b5e4dc8e0391
--- /dev/null
+++ b/tests/virnetdaemondata/input-data-no-keepalive-required.json
@@ -0,0 +1,124 @@
+{
+ "servers": [
+ {
+ "min_workers": 10,
+ "max_workers": 50,
+ "priority_workers": 5,
+ "max_clients": 100,
+ "keepaliveInterval": 120,
+ "keepaliveCount": 5,
+ "services": [
+ {
+ "auth": 0,
+ "readonly": true,
+ "nrequests_client_max": 2,
+ "socks": [
+ {
+ "fd": 100,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ },
+ {
+ "auth": 2,
+ "readonly": false,
+ "nrequests_client_max": 5,
+ "socks": [
+ {
+ "fd": 101,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ }
+ ],
+ "clients": [
+ {
+ "auth": 1,
+ "readonly": true,
+ "nrequests_max": 15,
+ "sock": {
+ "fd": 102,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ },
+ {
+ "auth": 2,
+ "readonly": true,
+ "nrequests_max": 66,
+ "sock": {
+ "fd": 103,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ }
+ ]
+ },
+ {
+ "min_workers": 2,
+ "max_workers": 50,
+ "priority_workers": 5,
+ "max_clients": 100,
+ "keepaliveInterval": 120,
+ "keepaliveCount": 5,
+ "services": [
+ {
+ "auth": 0,
+ "readonly": true,
+ "nrequests_client_max": 2,
+ "socks": [
+ {
+ "fd": 100,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ },
+ {
+ "auth": 2,
+ "readonly": false,
+ "nrequests_client_max": 5,
+ "socks": [
+ {
+ "fd": 101,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ }
+ ],
+ "clients": [
+ {
+ "auth": 1,
+ "readonly": true,
+ "nrequests_max": 15,
+ "sock": {
+ "fd": 102,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ },
+ {
+ "auth": 2,
+ "readonly": true,
+ "nrequests_max": 66,
+ "sock": {
+ "fd": 103,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/tests/virnetdaemondata/output-data-admin-nomdns.json b/tests/virnetdaemondata/output-data-admin-nomdns.json
index 5df71a0d88c8..a814aeb80614 100644
--- a/tests/virnetdaemondata/output-data-admin-nomdns.json
+++ b/tests/virnetdaemondata/output-data-admin-nomdns.json
@@ -8,7 +8,6 @@
"max_anonymous_clients": 100,
"keepaliveInterval": 120,
"keepaliveCount": 5,
- "keepaliveRequired": true,
"services": [
{
"auth": 0,
@@ -70,7 +69,6 @@
"max_anonymous_clients": 100,
"keepaliveInterval": 120,
"keepaliveCount": 5,
- "keepaliveRequired": true,
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemondata/output-data-anon-clients.json b/tests/virnetdaemondata/output-data-anon-clients.json
index 4e4332691aa7..05fc0ae00d3f 100644
--- a/tests/virnetdaemondata/output-data-anon-clients.json
+++ b/tests/virnetdaemondata/output-data-anon-clients.json
@@ -8,7 +8,6 @@
"max_anonymous_clients": 10,
"keepaliveInterval": 120,
"keepaliveCount": 5,
- "keepaliveRequired": true,
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemondata/output-data-initial-nomdns.json b/tests/virnetdaemondata/output-data-initial-nomdns.json
index bef54bf94ad5..400e47bc9463 100644
--- a/tests/virnetdaemondata/output-data-initial-nomdns.json
+++ b/tests/virnetdaemondata/output-data-initial-nomdns.json
@@ -8,7 +8,6 @@
"max_anonymous_clients": 100,
"keepaliveInterval": 120,
"keepaliveCount": 5,
- "keepaliveRequired": true,
"services": [
{
"auth": 0,
diff --git a/tests/virnetdaemondata/output-data-initial.json b/tests/virnetdaemondata/output-data-initial.json
index 9afa791d91fc..e875cffe5c01 100644
--- a/tests/virnetdaemondata/output-data-initial.json
+++ b/tests/virnetdaemondata/output-data-initial.json
@@ -8,7 +8,6 @@
"max_anonymous_clients": 100,
"keepaliveInterval": 120,
"keepaliveCount": 5,
- "keepaliveRequired": true,
"mdnsGroupName": "libvirtTest",
"services": [
{
diff --git a/tests/virnetdaemondata/output-data-no-keepalive-required.json b/tests/virnetdaemondata/output-data-no-keepalive-required.json
new file mode 100644
index 000000000000..b5e4dc8e0391
--- /dev/null
+++ b/tests/virnetdaemondata/output-data-no-keepalive-required.json
@@ -0,0 +1,124 @@
+{
+ "servers": [
+ {
+ "min_workers": 10,
+ "max_workers": 50,
+ "priority_workers": 5,
+ "max_clients": 100,
+ "keepaliveInterval": 120,
+ "keepaliveCount": 5,
+ "services": [
+ {
+ "auth": 0,
+ "readonly": true,
+ "nrequests_client_max": 2,
+ "socks": [
+ {
+ "fd": 100,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ },
+ {
+ "auth": 2,
+ "readonly": false,
+ "nrequests_client_max": 5,
+ "socks": [
+ {
+ "fd": 101,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ }
+ ],
+ "clients": [
+ {
+ "auth": 1,
+ "readonly": true,
+ "nrequests_max": 15,
+ "sock": {
+ "fd": 102,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ },
+ {
+ "auth": 2,
+ "readonly": true,
+ "nrequests_max": 66,
+ "sock": {
+ "fd": 103,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ }
+ ]
+ },
+ {
+ "min_workers": 2,
+ "max_workers": 50,
+ "priority_workers": 5,
+ "max_clients": 100,
+ "keepaliveInterval": 120,
+ "keepaliveCount": 5,
+ "services": [
+ {
+ "auth": 0,
+ "readonly": true,
+ "nrequests_client_max": 2,
+ "socks": [
+ {
+ "fd": 100,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ },
+ {
+ "auth": 2,
+ "readonly": false,
+ "nrequests_client_max": 5,
+ "socks": [
+ {
+ "fd": 101,
+ "errfd": -1,
+ "pid": 0,
+ "isClient": false
+ }
+ ]
+ }
+ ],
+ "clients": [
+ {
+ "auth": 1,
+ "readonly": true,
+ "nrequests_max": 15,
+ "sock": {
+ "fd": 102,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ },
+ {
+ "auth": 2,
+ "readonly": true,
+ "nrequests_max": 66,
+ "sock": {
+ "fd": 103,
+ "errfd": -1,
+ "pid": -1,
+ "isClient": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c
index ef45018f5873..fb8a6c0c0ec5 100644
--- a/tests/virnetdaemontest.c
+++ b/tests/virnetdaemontest.c
@@ -50,7 +50,7 @@ testCreateServer(const char *host, int family)
}
if (!(srv = virNetServerNew(10, 50, 5, 100, 10,
- 120, 5, true,
+ 120, 5,
mdns_group,
NULL,
NULL,
--
2.5.0
9 years, 4 months
[libvirt] [PATCH 0/2] Added waiting for DAD to finish for bridge address.
by Maxim Perevedentsev
This is a fix for commit db488c79173b240459c7754f38c3c6af9b432970
dnsmasq main process which is relied on when waiting for DAD to complete
exits without actually waiting for DAD. This is dnsmasq daemon's task.
It seems to be a race that DAD finished before dnsmasq main process exited.
The above commit needs the execution to block until DAD finishes
for bridge IPv6 address because then it closes dummy tap device.
Thus we need to ensure this ourselves.
So we periodically poll the kernel using netlink and
check whether there are any IPv6 addresses assigned to bridge
which have 'tentative' state. After DAD is finished, execution continues.
I guess that is what dnsmasq was assumed to do.
We use netlink to dump information about existing IPv6 addresses. Netlink's
response is a multi-part message. Unfortunately, the current implementation
of virNetlink treats such messages as faulty and throws an error. So the patch 2/2
adds multi-part nelink response support.
Maxim Perevedentsev (2):
network: added waiting for DAD to finish for bridge address.
netlink: add support for multi-part netlink messages.
src/network/bridge_driver.c | 109 +++++++++++++++++++++++++++++++++++++++++++-
src/util/virnetlink.c | 4 +-
2 files changed, 111 insertions(+), 2 deletions(-)
--
Sincerely,
Maxim Perevedentsev
9 years, 4 months
[libvirt] [PATCH] qemu: fail on attempts to use <filterref> for non-tap network connections
by Laine Stump
nwfilter uses iptables and ebtables, which only work properly on
tap-based network connections (*not* on macvtap, for example), but we
just ignore any <filterref> elements for other types of networks,
potentially giving users a false sense of security.
This patch checks the network type and fails/logs an error if any
domain <interface> has a <filterref> when the connection isn't using a
tap device.
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1180011
---
src/qemu/qemu_command.c | 11 +++++++++++
src/qemu/qemu_hotplug.c | 11 +++++++++++
2 files changed, 22 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e12278c..829f1dc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8581,6 +8581,17 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
return -1;
}
+ /* and only TAP devices support nwfilter rules */
+ if (net->filter &&
+ !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("filterref is not supported for "
+ "network interfaces of type %s"),
+ virDomainNetTypeToString(actualType));
+ return -1;
+ }
+
if (net->backend.tap &&
!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1ea397f..aabdb78 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -910,6 +910,17 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
return -1;
}
+ /* and only TAP devices support nwfilter rules */
+ if (net->filter &&
+ !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("filterref is not supported for "
+ "network interfaces of type %s"),
+ virDomainNetTypeToString(actualType));
+ return -1;
+ }
+
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_NETWORK) {
tapfdSize = vhostfdSize = net->driver.virtio.queues;
--
2.1.0
9 years, 4 months
[libvirt] [PATCH] virt drivers: show used memory as 0 when domain is inactive
by Jim Fehlig
Commit 1ce7c1d2 changed domainGetInfo to set virDomainInfoPtr->memory
to 0 when domain is inactive, but only did this for the LXC and QEMU
drivers. Make a similar change to the other virt drivers so they all
behave the same.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
FYI, commit 1ce7c1d2 also broke libvirt-tck 110-memory-balloon.t test
not ok 13 - Get current memory is 924288
Failed test 'Get current memory is 924288'
at /usr/share/libvirt-tck/tests/domain/110-memory-balloon.t line 120.
got: '0'
expected: '924288'
A patch to fix the TCK test has been added to my TODO list.
src/bhyve/bhyve_driver.c | 4 ++--
src/hyperv/hyperv_driver.c | 3 ++-
src/libxl/libxl_driver.c | 4 ++--
src/openvz/openvz_driver.c | 10 ++++++----
src/phyp/phyp_driver.c | 10 +++++++---
src/uml/uml_driver.c | 8 ++++----
src/vmware/vmware_driver.c | 6 ++++--
src/vz/vz_driver.c | 6 ++++--
src/xen/xen_driver.c | 2 ++
src/xen/xen_hypervisor.c | 7 ++++---
src/xen/xend_internal.c | 8 +++++---
src/xen/xm_internal.c | 3 ---
src/xenapi/xenapi_driver.c | 7 +++++--
13 files changed, 47 insertions(+), 31 deletions(-)
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 7f365b1..a85f7c7 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -295,11 +295,11 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
if (virDomainGetInfoEnsureACL(domain->conn, vm->def) < 0)
goto cleanup;
+ memset(info, 0, sizeof(*info));
+
if (virDomainObjIsActive(vm)) {
if (virBhyveGetDomainTotalCpuStats(vm, &(info->cpuTime)) < 0)
goto cleanup;
- } else {
- info->cpuTime = 0;
}
info->state = virDomainObjGetState(vm, NULL);
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index b539541..2524878 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -713,8 +713,9 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
/* Fill struct */
info->state = hypervMsvmComputerSystemEnabledStateToDomainState(computerSystem);
+ if (info->state != VIR_DOMAIN_SHUTOFF)
+ info->memory = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
info->maxMem = memorySettingData->data->Limit * 1024; /* megabyte to kilobyte */
- info->memory = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */
info->nrVirtCpu = processorSettingData->data->VirtualQuantity;
info->cpuTime = 0;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5f69b49..9d9b9a6 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1577,9 +1577,9 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ memset(info, 0, sizeof(*info));
+
if (!virDomainObjIsActive(vm)) {
- info->cpuTime = 0;
- info->memory = vm->def->mem.cur_balloon;
info->maxMem = virDomainDefGetMemoryActual(vm->def);
} else {
if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) != 0) {
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index fc8db7e..6005946 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -449,13 +449,13 @@ static int openvzDomainGetInfo(virDomainPtr dom,
goto cleanup;
}
+ memset(info, 0, sizeof(*info));
+
if (openvzGetVEStatus(vm, &state, NULL) == -1)
goto cleanup;
info->state = state;
- if (info->state != VIR_DOMAIN_RUNNING) {
- info->cpuTime = 0;
- } else {
+ if (info->state == VIR_DOMAIN_RUNNING) {
if (openvzGetProcessInfo(&(info->cpuTime), dom->id) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("cannot read cputime for domain %d"), dom->id);
@@ -463,8 +463,10 @@ static int openvzDomainGetInfo(virDomainPtr dom,
}
}
+ if (info->state != VIR_DOMAIN_SHUTOFF)
+ info->memory = vm->def->mem.cur_balloon;
+
info->maxMem = virDomainDefGetMemoryActual(vm->def);
- info->memory = vm->def->mem.cur_balloon;
info->nrVirtCpu = vm->def->vcpus;
ret = 0;
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 54dec70..c35675a 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3402,15 +3402,19 @@ phypDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
phyp_driverPtr phyp_driver = dom->conn->privateData;
char *managed_system = phyp_driver->managed_system;
+ memset(info, 0, sizeof(*info));
+
info->state = phypGetLparState(dom->conn, dom->id);
if ((info->maxMem =
phypGetLparMem(dom->conn, managed_system, dom->id, 0)) == 0)
VIR_WARN("Unable to determine domain's max memory.");
- if ((info->memory =
- phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0)
- VIR_WARN("Unable to determine domain's memory.");
+ if (info->state != VIR_DOMAIN_SHUTOFF) {
+ if ((info->memory =
+ phypGetLparMem(dom->conn, managed_system, dom->id, 1)) == 0)
+ VIR_WARN("Unable to determine domain's memory.");
+ }
if ((info->nrVirtCpu =
phypGetLparCPU(dom->conn, managed_system, dom->id)) == 0)
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c3c5fa7..5d05da1 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1900,20 +1900,20 @@ static int umlDomainGetInfo(virDomainPtr dom,
if (virDomainGetInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ memset(info, 0, sizeof(*info));
+
info->state = virDomainObjGetState(vm, NULL);
- if (!virDomainObjIsActive(vm)) {
- info->cpuTime = 0;
- } else {
+ if (virDomainObjIsActive(vm)) {
if (umlGetProcessInfo(&(info->cpuTime), vm->pid) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot read cputime for domain"));
goto cleanup;
}
+ info->memory = vm->def->mem.cur_balloon;
}
info->maxMem = virDomainDefGetMemoryActual(vm->def);
- info->memory = vm->def->mem.cur_balloon;
info->nrVirtCpu = vm->def->vcpus;
ret = 0;
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index ec74fe3..d42f6b7 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -1123,13 +1123,15 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
goto cleanup;
}
+ memset(info, 0, sizeof(*info));
+
if (vmwareUpdateVMStatus(driver, vm) < 0)
goto cleanup;
info->state = virDomainObjGetState(vm, NULL);
- info->cpuTime = 0;
+ if (info->state != VIR_DOMAIN_SHUTOFF)
+ info->memory = vm->def->mem.cur_balloon;
info->maxMem = virDomainDefGetMemoryActual(vm->def);
- info->memory = vm->def->mem.cur_balloon;
info->nrVirtCpu = vm->def->vcpus;
ret = 0;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 8fa7957..2cef2e1 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -563,11 +563,13 @@ vzDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
if (!(privdom = vzDomObjFromDomain(domain)))
goto cleanup;
+ memset(info, 0, sizeof(*info));
+
info->state = virDomainObjGetState(privdom, NULL);
- info->memory = privdom->def->mem.cur_balloon;
+ if (info->state != VIR_DOMAIN_SHUTOFF)
+ info->memory = privdom->def->mem.cur_balloon;
info->maxMem = virDomainDefGetMemoryActual(privdom->def);
info->nrVirtCpu = privdom->def->vcpus;
- info->cpuTime = 0;
ret = 0;
cleanup:
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index ce31f0f..3d0bb08 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1173,6 +1173,8 @@ xenUnifiedDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
if (virDomainGetInfoEnsureACL(dom->conn, def) < 0)
goto cleanup;
+ memset(info, 0, sizeof(*info));
+
if (def->id < 0) {
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
ret = xenXMDomainGetInfo(dom->conn, def, info);
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 431c47a..920dae1 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2776,7 +2776,6 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
kb_per_pages = 4;
}
- memset(info, 0, sizeof(virDomainInfo));
XEN_GETDOMAININFO_CLEAR(dominfo);
ret = virXen_getdomaininfo(priv->handle, id, &dominfo);
@@ -2820,8 +2819,10 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
* convert to microseconds, same thing convert to
* kilobytes from page counts
*/
- info->cpuTime = XEN_GETDOMAININFO_CPUTIME(dominfo);
- info->memory = XEN_GETDOMAININFO_TOT_PAGES(dominfo) * kb_per_pages;
+ if (info->state != VIR_DOMAIN_SHUTOFF) {
+ info->cpuTime = XEN_GETDOMAININFO_CPUTIME(dominfo);
+ info->memory = XEN_GETDOMAININFO_TOT_PAGES(dominfo) * kb_per_pages;
+ }
info->maxMem = XEN_GETDOMAININFO_MAX_PAGES(dominfo);
if (info->maxMem != UINT_MAX)
info->maxMem *= kb_per_pages;
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index b81c0b7..1de642e 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -953,10 +953,12 @@ sexpr_to_xend_domain_info(virDomainDefPtr def,
int vcpus;
info->state = sexpr_to_xend_domain_state(def, root);
- info->memory = sexpr_u64(root, "domain/memory") << 10;
+ if (info->state != VIR_DOMAIN_SHUTOFF) {
+ info->memory = sexpr_u64(root, "domain/memory") << 10;
+ info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
+ }
+
info->maxMem = sexpr_u64(root, "domain/maxmem") << 10;
- info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
-
vcpus = sexpr_int(root, "domain/vcpus");
info->nrVirtCpu = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail"));
if (!info->nrVirtCpu || vcpus < info->nrVirtCpu)
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 59b1cd4..4a49014 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -481,12 +481,9 @@ xenXMDomainGetInfo(virConnectPtr conn,
if (!(entry = virHashLookup(priv->configCache, filename)))
goto error;
- memset(info, 0, sizeof(virDomainInfo));
info->maxMem = virDomainDefGetMemoryActual(entry->def);
- info->memory = entry->def->mem.cur_balloon;
info->nrVirtCpu = entry->def->vcpus;
info->state = VIR_DOMAIN_SHUTOFF;
- info->cpuTime = 0;
xenUnifiedUnlock(priv);
return 0;
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 11f6e91..b052f63 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1074,7 +1074,9 @@ xenapiDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
xen_vm_record *record;
xen_vm_set *vms;
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
- info->cpuTime = 0; /* CPU time is not advertised */
+
+ memset(info, 0, sizeof(*info));
+
if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
if (vms->size != 1) {
xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
@@ -1091,7 +1093,8 @@ xenapiDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
xen_vm_get_record(session, &record, vm);
if (record != NULL) {
xen_vm_metrics_get_memory_actual(session, &memory, record->metrics->u.handle);
- info->memory = (memory / 1024);
+ if (info->state != VIR_DOMAIN_SHUTOFF)
+ info->memory = (memory / 1024);
xen_vm_record_free(record);
}
xen_vm_get_vcpus_max(session, &vcpu, vm);
--
2.1.4
9 years, 4 months
[libvirt] [PATCH] fix typo in comments
by Cao jin
Signed-off-by: Cao jin <caoj.fnst(a)cn.fujitsu.com>
---
src/datatypes.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/datatypes.h b/src/datatypes.h
index c498cb0..be108fe 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -383,7 +383,7 @@ struct _virConnect {
/* Per-connection error. */
virError err; /* the last error */
- virErrorFunc handler; /* associated handlet */
+ virErrorFunc handler; /* associated handler */
void *userData; /* the user data */
/* Per-connection close callback */
--
2.1.0
9 years, 4 months