View | Details | Raw Unified | Return to bug 34920
Collapse All | Expand All

(-)/usr/lib/python2.7/site-packages/nova/virt/disk/api.py.old (-2 / +2 lines)
Lines 137-150 Link Here
137
                      run_as_root=run_as_root)
137
                      run_as_root=run_as_root)
138
138
139
139
140
def get_disk_size(path):
140
def get_disk_size(path, force_share=False):
141
    """Get the (virtual) size of a disk image
141
    """Get the (virtual) size of a disk image
142
142
143
    :param path: Path to the disk image
143
    :param path: Path to the disk image
144
    :returns: Size (in bytes) of the given disk image as it would be seen
144
    :returns: Size (in bytes) of the given disk image as it would be seen
145
              by a virtual machine.
145
              by a virtual machine.
146
    """
146
    """
147
    return images.qemu_img_info(path).virtual_size
147
    return images.qemu_img_info(path, force_share=force_share).virtual_size
148
148
149
149
150
def extend(image, size):
150
def extend(image, size):
(-)/usr/lib/python2.7/site-packages/nova/virt/images.py.old (-1 / +3 lines)
Lines 43-49 Link Here
43
    address_space=1 * units.Gi)
43
    address_space=1 * units.Gi)
44
44
45
45
46
def qemu_img_info(path, format=None):
46
def qemu_img_info(path, format=None, force_share=False):
47
    """Return an object containing the parsed output from qemu-img info."""
47
    """Return an object containing the parsed output from qemu-img info."""
48
    # TODO(mikal): this code should not be referring to a libvirt specific
48
    # TODO(mikal): this code should not be referring to a libvirt specific
49
    # flag.
49
    # flag.
Lines 56-61 Link Here
56
56
57
    try:
57
    try:
58
        cmd = ('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info', path)
58
        cmd = ('env', 'LC_ALL=C', 'LANG=C', 'qemu-img', 'info', path)
59
        if force_share:
60
            cmd = cmd + ('--force-share',)
59
        if format is not None:
61
        if format is not None:
60
            cmd = cmd + ('-f', format)
62
            cmd = cmd + ('-f', format)
61
        out, err = utils.execute(*cmd, prlimit=QEMU_IMG_LIMITS)
63
        out, err = utils.execute(*cmd, prlimit=QEMU_IMG_LIMITS)
(-)/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py.old (-9 / +43 lines)
Lines 403-408 Link Here
403
# for all architectures/hypervisors, as this value rises to
403
# for all architectures/hypervisors, as this value rises to
404
# meet them.
404
# meet them.
405
MIN_LIBVIRT_VERSION = (0, 10, 2)
405
MIN_LIBVIRT_VERSION = (0, 10, 2)
406
MIN_QEMU_VERSION = (2, 1, 0)
406
# TODO(berrange): Re-evaluate this at start of each release cycle
407
# TODO(berrange): Re-evaluate this at start of each release cycle
407
# to decide if we want to plan a future min version bump.
408
# to decide if we want to plan a future min version bump.
408
# MIN_LIBVIRT_VERSION can be updated to match this after
409
# MIN_LIBVIRT_VERSION can be updated to match this after
Lines 482-487 Link Here
482
# libvirt 1.3 fix f391889f4e942e22b9ef8ecca492de05106ce41e
483
# libvirt 1.3 fix f391889f4e942e22b9ef8ecca492de05106ce41e
483
MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION = (1, 3, 0)
484
MIN_LIBVIRT_PF_WITH_NO_VFS_CAP_VERSION = (1, 3, 0)
484
485
486
# qemu >= 2.10.0
487
# Use '--force-share' to skip image locking during qemu-img info
488
# execution as running qemu process owns the write lock.
489
MIN_QEMU_FORCE_SHARE = (2, 10, 0)
490
485
# ppc64/ppc64le architectures with KVM
491
# ppc64/ppc64le architectures with KVM
486
# NOTE(rfolco): Same levels for Libvirt/Qemu on Big Endian and Little
492
# NOTE(rfolco): Same levels for Libvirt/Qemu on Big Endian and Little
487
# Endian giving the nuance around guest vs host architectures
493
# Endian giving the nuance around guest vs host architectures
Lines 580-585 Link Here
580
        self._remotefs = remotefs.RemoteFilesystem()
586
        self._remotefs = remotefs.RemoteFilesystem()
581
587
582
        self._live_migration_flags = self._block_migration_flags = None
588
        self._live_migration_flags = self._block_migration_flags = None
589
        
590
        # Assume pre 2.10 version of qemu is in use
591
        self._force_share = False
583
592
584
    def _get_volume_drivers(self):
593
    def _get_volume_drivers(self):
585
        return libvirt_volume_drivers
594
        return libvirt_volume_drivers
Lines 664-669 Link Here
664
                _('Nova requires libvirt version %s or greater.') %
673
                _('Nova requires libvirt version %s or greater.') %
665
                self._version_to_string(MIN_LIBVIRT_VERSION))
674
                self._version_to_string(MIN_LIBVIRT_VERSION))
666
675
676
        if CONF.libvirt.virt_type in ("qemu", "kvm"):
677
            if self._host.has_min_version(hv_ver=MIN_QEMU_VERSION):
678
                self._force_share = (
679
                    self._host.has_min_version(hv_ver=MIN_QEMU_FORCE_SHARE)
680
                )
681
            else:
682
                raise exception.InternalError(
683
                    _('Nova requires QEMU version %s or greater.') %
684
                    self._version_to_string(MIN_QEMU_VERSION))
685
667
        if (CONF.libvirt.virt_type == 'parallels' and
686
        if (CONF.libvirt.virt_type == 'parallels' and
668
            not self._host.has_min_version(MIN_LIBVIRT_PARALLELS_VERSION)):
687
            not self._host.has_min_version(MIN_LIBVIRT_PARALLELS_VERSION)):
669
            raise exception.NovaException(
688
            raise exception.NovaException(
Lines 1858-1871 Link Here
1858
        #             in QEMU 1.3. In order to do this, we need to create
1877
        #             in QEMU 1.3. In order to do this, we need to create
1859
        #             a destination image with the original backing file
1878
        #             a destination image with the original backing file
1860
        #             and matching size of the instance root disk.
1879
        #             and matching size of the instance root disk.
1861
        src_disk_size = libvirt_utils.get_disk_size(disk_path,
1880
        src_disk_size = libvirt_utils.get_disk_size(
1862
                                                    format=source_format)
1881
            disk_path,
1863
        src_back_path = libvirt_utils.get_disk_backing_file(disk_path,
1882
            format=source_format,
1864
                                                        format=source_format,
1883
            force_share=self._force_share
1865
                                                        basename=False)
1884
        )
1885
        src_back_path = libvirt_utils.get_disk_backing_file(
1886
            disk_path,
1887
            format=source_format,
1888
            basename=False,
1889
            force_share=self._force_share
1890
        )
1866
        disk_delta = out_path + '.delta'
1891
        disk_delta = out_path + '.delta'
1867
        libvirt_utils.create_cow_image(src_back_path, disk_delta,
1892
        libvirt_utils.create_cow_image(
1868
                                       src_disk_size)
1893
            src_back_path, disk_delta,
1894
            src_disk_size,
1895
            force_share=self._force_share
1896
        )
1869
1897
1870
        quiesced = False
1898
        quiesced = False
1871
        try:
1899
        try:
Lines 6996-7003 Link Here
6996
7024
6997
            disk_type = driver_nodes[cnt].get('type')
7025
            disk_type = driver_nodes[cnt].get('type')
6998
            if disk_type == "qcow2":
7026
            if disk_type == "qcow2":
6999
                backing_file = libvirt_utils.get_disk_backing_file(path)
7027
                backing_file = libvirt_utils.get_disk_backing_file(
7000
                virt_size = disk.get_disk_size(path)
7028
                    path,
7029
                    force_share=self._force_share
7030
                )
7031
                virt_size = disk.get_disk_size(
7032
                    path,
7033
                    force_share=self._force_share
7034
                )
7001
                over_commit_size = int(virt_size) - dk_size
7035
                over_commit_size = int(virt_size) - dk_size
7002
            else:
7036
            else:
7003
                backing_file = ""
7037
                backing_file = ""
(-)/usr/lib/python2.7/site-packages/nova/virt/libvirt/utils.py.old (-6 / +9 lines)
Lines 75-81 Link Here
75
    execute('qemu-img', 'create', '-f', disk_format, path, size)
75
    execute('qemu-img', 'create', '-f', disk_format, path, size)
76
76
77
77
78
def create_cow_image(backing_file, path, size=None):
78
def create_cow_image(backing_file, path, size=None, force_share=False):
79
    """Create COW image
79
    """Create COW image
80
80
81
    Creates a COW image with the given backing file
81
    Creates a COW image with the given backing file
Lines 87-93 Link Here
87
    cow_opts = []
87
    cow_opts = []
88
    if backing_file:
88
    if backing_file:
89
        cow_opts += ['backing_file=%s' % backing_file]
89
        cow_opts += ['backing_file=%s' % backing_file]
90
        base_details = images.qemu_img_info(backing_file)
90
        base_details = images.qemu_img_info(backing_file,
91
                                            force_share=force_share)
91
    else:
92
    else:
92
        base_details = None
93
        base_details = None
93
    # Explicitly inherit the value of 'cluster_size' property of a qcow2
94
    # Explicitly inherit the value of 'cluster_size' property of a qcow2
Lines 163-187 Link Here
163
        return None
164
        return None
164
165
165
166
166
def get_disk_size(path, format=None):
167
def get_disk_size(path, format=None, force_share=False):
167
    """Get the (virtual) size of a disk image
168
    """Get the (virtual) size of a disk image
168
169
169
    :param path: Path to the disk image
170
    :param path: Path to the disk image
170
    :param format: the on-disk format of path
171
    :param format: the on-disk format of path
172
    :param force_share: Inhibit write lock during qemu-img info call
171
    :returns: Size (in bytes) of the given disk image as it would be seen
173
    :returns: Size (in bytes) of the given disk image as it would be seen
172
              by a virtual machine.
174
              by a virtual machine.
173
    """
175
    """
174
    size = images.qemu_img_info(path, format).virtual_size
176
    size = images.qemu_img_info(path, format, force_share).virtual_size
175
    return int(size)
177
    return int(size)
176
178
177
179
178
def get_disk_backing_file(path, basename=True, format=None):
180
def get_disk_backing_file(path, basename=True, format=None, force_share=False):
179
    """Get the backing file of a disk image
181
    """Get the backing file of a disk image
180
182
181
    :param path: Path to the disk image
183
    :param path: Path to the disk image
184
    :param force_share: Inhibit write lock during qemu-img info cal
182
    :returns: a path to the image's backing store
185
    :returns: a path to the image's backing store
183
    """
186
    """
184
    backing_file = images.qemu_img_info(path, format).backing_file
187
    backing_file = images.qemu_img_info(path, format, force_share).backing_file
185
    if backing_file and basename:
188
    if backing_file and basename:
186
        backing_file = os.path.basename(backing_file)
189
        backing_file = os.path.basename(backing_file)
187
190

Return to bug 34920