dom0/qvm-prefs: add missing exit(1) on invalid arguments

This commit is contained in:
Marek Marczykowski 2012-03-02 16:17:18 +01:00
parent 7c9075d09b
commit 7a3b9d0033

View File

@ -28,6 +28,7 @@ from optparse import OptionParser
import subprocess
import os
import sys
import re
def do_list(vm):
label_width = 18
@ -57,6 +58,7 @@ def do_list(vm):
print fmt.format ("vcpus", str(vm.vcpus))
print fmt.format ("memory", vm.memory)
print fmt.format ("maxmem", vm.maxmem)
print fmt.format ("MAC", "%s%s" % (vm.mac, " (auto)" if vm._mac is None else ""))
if vm.template_vm is not None:
print fmt.format ("kernel", "%s (from template)" % vm.kernel)
elif vm.uses_default_kernel:
@ -86,18 +88,38 @@ def set_label(vms, vm, args):
def set_memory(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing memory argument!"
exit (1)
vm.memory = int(args[0])
def set_maxmem(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing maxmem argument!"
exit (1)
vm.maxmem = int(args[0])
def set_mac(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing MAC argument!"
exit (1)
if not re.match("[0-9a-fA-F:]{17}|auto", args[0]):
print >> sys.stderr, "Invalid MAC argument!"
print >> sys.stderr, "Possible values:"
print >> sys.stderr, "1) auto"
print >> sys.stderr, "2) MAC in format: XX:XX:XX:XX:XX:XX"
exit (1)
mac = args[0]
if mac == "auto":
mac = None
vm.mac = mac
def set_pcidevs(vms, vm, args):
if len (args) != 1:
print >> sys.stderr, "Missing pcidevs argument!"
exit (1)
vm.pcidevs = list(eval(args[0]))
@ -301,6 +323,7 @@ properties = {
"vcpus" : set_vcpus,
"kernelopts": set_kernelopts,
"name": set_name,
"mac": set_mac,
}