Revision 27b6654e lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
34 | 34 |
import struct |
35 | 35 |
import fcntl |
36 | 36 |
import shutil |
37 |
import urllib2 |
|
37 | 38 |
import socket |
38 | 39 |
import stat |
39 | 40 |
import StringIO |
... | ... | |
318 | 319 |
return (ifname, tapfd) |
319 | 320 |
|
320 | 321 |
|
322 |
def _CheckUrl(url): |
|
323 |
"""Check if a given URL exists on the server |
|
324 |
|
|
325 |
""" |
|
326 |
req = urllib2.Request(url) |
|
327 |
|
|
328 |
# XXX: ugly but true |
|
329 |
req.get_method = lambda: "HEAD" |
|
330 |
|
|
331 |
try: |
|
332 |
resp = urllib2.urlopen(req) |
|
333 |
except urllib2.URLError: |
|
334 |
return False |
|
335 |
|
|
336 |
del resp |
|
337 |
return True |
|
338 |
|
|
339 |
|
|
321 | 340 |
class QmpMessage: |
322 | 341 |
"""QEMU Messaging Protocol (QMP) message. |
323 | 342 |
|
... | ... | |
1427 | 1446 |
iso_image = hvp[constants.HV_CDROM_IMAGE_PATH] |
1428 | 1447 |
if iso_image: |
1429 | 1448 |
options = ",media=cdrom" |
1430 |
if not re.match(r'(https?|ftps?)://', iso_image): |
|
1449 |
if re.match(r'(https?|ftps?)://', iso_image): |
|
1450 |
# Check that the iso image is really there |
|
1451 |
# See https://bugs.launchpad.net/qemu/+bug/597575 |
|
1452 |
if not _CheckUrl(iso_image): |
|
1453 |
raise errors.HypervisorError("ISO image %s is not accessible" % |
|
1454 |
iso_image) |
|
1455 |
else: |
|
1431 | 1456 |
options = "%s,format=raw" % options |
1432 | 1457 |
# set cdrom 'if' type |
1433 | 1458 |
if boot_cdrom: |
Also available in: Unified diff