Merge branch 'master' into pvusb2

This commit is contained in:
Alexandre Bezroutchko 2012-11-08 10:51:18 +01:00
commit 8ce7a91649
3 changed files with 13 additions and 11 deletions

View File

@ -408,6 +408,7 @@ def block_detach_all(vm, vm_xid = None):
usb_ver_re = re.compile(r"^(1|2)$")
usb_device_re = re.compile(r"^[0-9]+-[0-9]+(_[0-9]+)?$")
usb_port_re = re.compile(r"^$|^[0-9]+-[0-9]+(\.[0-9]+)?$")
def usb_setup(backend_vm_xid, vm_xid, devid, usb_ver):
"""
@ -548,15 +549,15 @@ def usb_check_attached(xs_trans, backend_vm, device):
if not port.isdigit():
print >> sys.stderr, "Invalid port in VM %s frontend %s" % (vm, frontend)
continue
xs_encoded_dev = xs.read(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port/%s' % (backend_vm, vm, frontend_dev, port))
if xs_encoded_dev == "":
dev = xs.read(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port/%s' % (backend_vm, vm, frontend_dev, port))
if dev == "":
continue
# Sanitize device id
if not usb_device_re.match(xs_encoded_dev):
if not usb_port_re.match(dev):
print >> sys.stderr, "Invalid device id in backend VM %d @ %s/%s/port/%s" % \
(backend_vm, vm, frontend_dev, port)
continue
if usb_decode_device_from_xs(xs_encoded_dev) == device:
if dev == device:
frontend = "%s-%s" % (frontend_dev, port)
vm_name = xl_ctx.domid_to_name(int(vm))
if vm_name is None:
@ -609,13 +610,13 @@ def usb_find_unused_frontend(xs_trans, backend_vm_xid, vm_xid, usb_ver):
print >> sys.stderr, "Invalid port in VM %d frontend_dev %d" % (vm_xid, frontend_dev)
continue
port = int(port)
xs_encoded_dev = xs.read(xs_trans, '/local/domain/%d/backend/vusb/%d/%d/port/%d' % (backend_vm_xid, vm_xid, frontend_dev, port))
dev = xs.read(xs_trans, '/local/domain/%d/backend/vusb/%s/%s/port/%s' % (backend_vm, vm, frontend_dev, port))
# Sanitize device id
if xs_encoded_dev != "" and not usb_device_re.match(xs_encoded_dev):
if not usb_port_re.match(dev):
print >> sys.stderr, "Invalid device id in backend VM %d @ %d/%d/port/%d" % \
(backend_vm_xid, vm_xid, frontend_dev, port)
continue
if xs_encoded_dev == "":
if dev == "":
return '%d-%d' % (frontend_dev, port)
last_frontend_dev = frontend_dev

View File

@ -111,7 +111,7 @@ def main():
if options.template is not None:
template = qvm_collection.get_vm_by_name(options.template)
if template is None:
print >> sys.stderr, "There is no (Templete)VM with the name '{0}'".format(options.template)
print >> sys.stderr, "There is no (Template)VM with the name '{0}'".format(options.template)
exit (1)
if not template.is_template():
print >> sys.stderr, "VM '{0}' is not a TemplateVM".format(options.template)
@ -121,7 +121,7 @@ def main():
elif not options.hvm:
if qvm_collection.get_default_template() is None:
print >> sys.stderr, "No default TempleteVM defined!"
print >> sys.stderr, "No default TemplateVM defined!"
exit (1)
else:
template = qvm_collection.get_default_template()

View File

@ -53,11 +53,12 @@ def main():
print >> sys.stderr, "******* WARNING *** WARNING *** WARNING *** WARNING *******"
print >> sys.stderr, "*** ***"
print >> sys.stderr, "*** PVUSB passthrough kernel support is still unstable. ***"
print >> sys.stderr, "*** It can CRASH your VMs ***"
print >> sys.stderr, "*** It can CRASH your VMs. ***"
print >> sys.stderr, "*** ***"
print >> sys.stderr, "***********************************************************"
print >> sys.stderr, ""
print >> sys.stderr, "If you still want to use it, type capital YES"
print >> sys.stderr, "To use it, you need install kernel from \"unstable\" repository"
print >> sys.stderr, "If you still want to enable it, type capital YES"
print >> sys.stderr, ""
prompt = raw_input ("Do you want enable PV USB support? ")
if prompt == "YES":