openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #13106
Re: File injection support
From: Scott Moser [mailto:ssmoser2@xxxxxxxxx] On Behalf Of Scott Moser
Sent: den 11 juni 2012 23:16
>...Without digging around on older versions of OS's and their included kernel/udev/kpartx.... i'd have to say that from your message above, and my testing that running 'kpartx' is no longer necessary. That can reasonably be expected to be created by >the kernel or some other plumbing bits automatically...
I just now tested to remove the kpartx invocation from /nova/virt/disk/mount.py, like this:
diff --git a/nova/virt/disk/mount.py b/nova/virt/disk/mount.py
index 11959b2..4d9527b 100644
--- a/nova/virt/disk/mount.py
+++ b/nova/virt/disk/mount.py
@@ -61,25 +61,9 @@ class Mount(object):
if self.partition == -1:
self.error = _('partition search unsupported with %s') % self.mode
elif self.partition:
- map_path = '/dev/mapper/%sp%s' % (os.path.basename(self.device),
- self.partition)
- assert(not os.path.exists(map_path))
-
- # Note kpartx can output warnings to stderr and succeed
- # Also it can output failures to stderr and "succeed"
- # So we just go on the existence of the mapped device
- _out, err = utils.trycmd('kpartx', '-a', self.device,
- run_as_root=True, discard_warnings=True)
-
- # Note kpartx does nothing when presented with a raw image,
- # so given we only use it when we expect a partitioned image, fail
- if not os.path.exists(map_path):
- if not err:
- err = _('partition %s not found') % self.partition
- self.error = _('Failed to map partitions: %s') % err
- else:
- self.mapped_device = map_path
- self.mapped = True
+ #qemu-nbd already has mapped the partition for mounting
+ self.mapped_device = '%sp%s' % (self.device, self.partition)
+ self.mapped = True
else:
self.mapped_device = self.device
self.mapped = True
@@ -90,8 +74,7 @@ class Mount(object):
"""Remove partitions of the device from the file system namespace."""
if not self.mapped:
return
- if self.partition:
- utils.execute('kpartx', '-d', self.device, run_as_root=True)
+ #No need to run kpartx
self.mapped = False
to rely on the qemu-nbd mapping. With the above change, file injection works fine with the CirrOS qcow2 image (I have not tested with any other image yet).
I run Ubuntu 12.04 Desktop with the 3.2.0-24-generic kernel and qemu-utils package version 1.0+noroms-0ubuntu13
Best Regards,
Fredric
Follow ups
References
-
File injection support
From: Nicolae Paladi, 2012-05-29
-
Re: File injection support
From: Pádraig Brady, 2012-05-29
-
Re: File injection support
From: Fredric Morenius, 2012-05-30
-
Re: File injection support
From: Pádraig Brady, 2012-05-30
-
Re: File injection support
From: Fredric Morenius, 2012-06-08
-
Re: File injection support
From: Pádraig Brady, 2012-06-08
-
Re: File injection support
From: Scott Moser, 2012-06-08
-
Re: File injection support
From: Pádraig Brady, 2012-06-08
-
Re: File injection support
From: Vishvananda Ishaya, 2012-06-10
-
Re: File injection support
From: Fredric Morenius, 2012-06-11
-
Re: File injection support
From: Scott Moser, 2012-06-11