mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
blktap: Automatically start tapdisk-ioemu on demand
When a domain wants to use a tap:ioemu disk but has no device model, start a tapdisk-ioemu instance as provider. Also, move the creation and removal of communication pipes to xend so that qemu-dm doesn't need the unwanted SIGHUP handler anymore. Signed-off-by: Kevin Wolf <kwolf@suse.de>
This commit is contained in:
1 parent
e76492c4f4
commit
defe5e9a30
8 files changed
+126
-65
No files matched your search
@@ -1837,6 +1837,9 @@ class XendDomainInfo:
|
||||
|
||||
@raise: VmError for invalid devices
|
||||
"""
|
||||
if self.image:
|
||||
self.image.prepareEnvironment()
|
||||
|
||||
ordered_refs = self.info.ordered_device_refs()
|
||||
for dev_uuid in ordered_refs:
|
||||
devclass, config = self.info['devices'][dev_uuid]
|
||||
|
||||
@@ -185,6 +185,42 @@ class ImageHandler:
|
||||
"""Build the domain. Define in subclass."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def prepareEnvironment(self):
|
||||
"""Prepare the environment for the execution of the domain. This
|
||||
method is called before any devices are set up."""
|
||||
|
||||
domid = self.vm.getDomid()
|
||||
|
||||
# Delete left-over pipes
|
||||
try:
|
||||
os.unlink('/var/run/tap/qemu-read-%d' % domid)
|
||||
os.unlink('/var/run/tap/qemu-write-%d' % domid)
|
||||
except:
|
||||
pass
|
||||
|
||||
# No device model, don't create pipes
|
||||
if self.device_model is None:
|
||||
return
|
||||
|
||||
# If we use a device model, the pipes for communication between
|
||||
# blktapctrl and ioemu must be present before the devices are
|
||||
# created (blktapctrl must access them for new block devices)
|
||||
|
||||
# mkdir throws an exception if the path already exists
|
||||
try:
|
||||
os.mkdir('/var/run/tap', 0755)
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.mkfifo('/var/run/tap/qemu-read-%d' % domid, 0600)
|
||||
os.mkfifo('/var/run/tap/qemu-write-%d' % domid, 0600)
|
||||
except OSError, e:
|
||||
log.warn('Could not create blktap pipes for domain %d' % domid)
|
||||
log.exception(e)
|
||||
pass
|
||||
|
||||
|
||||
# Return a list of cmd line args to the device models based on the
|
||||
# xm config file
|
||||
def parseDeviceModelArgs(self, vmConfig):
|
||||
@@ -411,6 +447,12 @@ class ImageHandler:
|
||||
self.pid = None
|
||||
state = xstransact.Remove("/local/domain/0/device-model/%i"
|
||||
% self.vm.getDomid())
|
||||
|
||||
try:
|
||||
os.unlink('/var/run/tap/qemu-read-%d' % self.vm.getDomid())
|
||||
os.unlink('/var/run/tap/qemu-write-%d' % self.vm.getDomid())
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
class LinuxImageHandler(ImageHandler):
|
||||
|
||||