Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 5c655bb31b7eacedb96e8b5da992c6ce > files > 19

openstack-nova-2011.3.1-11.fc16.src.rpm

From 2e1a3dd69f9d76b0e89d20661a2762f9fab4cab4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <pbrady@redhat.com>
Date: Tue, 10 Jan 2012 10:54:21 +0000
Subject: [PATCH] Fix libguestfs operation with specified partitions

* nova/virt/disk/guestfs.py (mnt_dev): Convert the partition
parameter to int, so we now support a "1" string passed from
nova/virt/libvirt/connection.py.  Also diagnose any
unconvertible strings.

Change-Id: I744bd1fc3ea065891b5ce112dbe27f73086f302e
---
 nova/virt/disk/guestfs.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/nova/virt/disk/guestfs.py b/nova/virt/disk/guestfs.py
index 6323dc8..20e3eda 100644
--- a/nova/virt/disk/guestfs.py
+++ b/nova/virt/disk/guestfs.py
@@ -33,11 +33,17 @@ class Mount(mount.Mount):
         self.mapped = False
 
     def mnt_dev(self):
+        try:
+            partition = int(self.partition or 0)
+        except ValueError:
+            self.error = _('unsupported partition: %s') % self.partition
+            return False
+
         args = ('guestmount', '--rw', '-a', self.image)
-        if self.partition == -1:
+        if partition == -1:
             args += ('-i',)  # find the OS partition
-        elif self.partition:
-            args += ('-m', '/dev/sda%d' % self.partition)
+        elif partition:
+            args += ('-m', '/dev/sda%d' % partition)
         else:
             # We don't resort to -i for this case yet,
             # as some older versions of libguestfs