---
tools/virsh.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index e5093a2..c9b4c57 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2285,7 +2285,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
{
int func_ret = FALSE;
int ret;
- int cell, cell_given;
+ int cell, cell_given, cell_opt_given;
unsigned long long memory;
xmlNodePtr *nodes = NULL;
unsigned long nodes_cnt;
@@ -2301,7 +2301,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
if (!vshConnectionUsability(ctl, ctl->conn))
return FALSE;
- cell = vshCommandOptInt(cmd, "cellno", &cell_given, NULL);
+ cell = vshCommandOptInt(cmd, "cellno", &cell_given,
&cell_opt_given);
all_given = vshCommandOptBool(cmd, "all");
if (all_given && cell_given) {
@@ -2310,6 +2310,11 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
+ if (!cell_given && cell_opt_given) {
+ vshError(ctl, "%s", _("cell number has to be a number"));
+ goto cleanup;
+ }
+
if (all_given) {
cap_xml = virConnectGetCapabilities(ctl->conn);
if (!cap_xml) {
@@ -2848,7 +2853,7 @@ static int
cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
- int count;
+ int count, opt_count;
int ret = TRUE;
int maximum = vshCommandOptBool(cmd, "maximum");
int config = vshCommandOptBool(cmd, "config");
@@ -2863,7 +2868,12 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return FALSE;
- count = vshCommandOptInt(cmd, "count", &count, NULL);
+ count = vshCommandOptInt(cmd, "count", &count, &opt_count);
+
+ if (!count && opt_count) {
+ vshError(ctl, "%s", _("count has to be a number"));
+ goto cleanup;
+ }
if (!flags) {
if (virDomainSetVcpus(dom, count) != 0) {
--
1.7.4