Skip to content

Commit

Permalink
remove auto fsck feature from file injection. Bug 826794
Browse files Browse the repository at this point in the history
This is at least independent of file injection,
and as noted in the bug report is questionable
to do anyway.

Change-Id: Iddd33c446bad2232ea2d47cc30778228d1d222b0
  • Loading branch information
Pádraig Brady committed Feb 2, 2012
1 parent def8544 commit a8104eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
16 changes: 5 additions & 11 deletions nova/virt/disk/api.py
Expand Up @@ -109,12 +109,10 @@ def extend(image, size):
class _DiskImage(object):
"""Provide operations on a disk image file."""

def __init__(self, image, partition=None, use_cow=False,
disable_auto_fsck=False, mount_dir=None):
def __init__(self, image, partition=None, use_cow=False, mount_dir=None):
# These passed to each mounter
self.image = image
self.partition = partition
self.disable_auto_fsck = disable_auto_fsck
self.mount_dir = mount_dir

# Internal
Expand Down Expand Up @@ -164,7 +162,6 @@ def mount(self):
mounter_cls = self._handler_class(h)
mounter = mounter_cls(image=self.image,
partition=self.partition,
disable_auto_fsck=self.disable_auto_fsck,
mount_dir=self.mount_dir)
if mounter.do_mount():
self._mounter = mounter
Expand All @@ -191,7 +188,7 @@ def umount(self):
# Public module functions

def inject_data(image, key=None, net=None, metadata=None,
partition=None, use_cow=False, disable_auto_fsck=True):
partition=None, use_cow=False):
"""Injects a ssh key and optionally net data into a disk image.
it will mount the image as a fully partitioned disk and attempt to inject
Expand All @@ -200,8 +197,7 @@ def inject_data(image, key=None, net=None, metadata=None,
If partition is not specified it mounts the image as a single partition.
"""
img = _DiskImage(image=image, partition=partition, use_cow=use_cow,
disable_auto_fsck=disable_auto_fsck)
img = _DiskImage(image=image, partition=partition, use_cow=use_cow)
if img.mount():
try:
inject_data_into_fs(img.mount_dir, key, net, metadata,
Expand All @@ -212,11 +208,9 @@ def inject_data(image, key=None, net=None, metadata=None,
raise exception.Error(img.errors)


def inject_files(image, files, partition=None, use_cow=False,
disable_auto_fsck=True):
def inject_files(image, files, partition=None, use_cow=False):
"""Injects arbitrary files into a disk image"""
img = _DiskImage(image=image, partition=partition, use_cow=use_cow,
disable_auto_fsck=disable_auto_fsck)
img = _DiskImage(image=image, partition=partition, use_cow=use_cow)
if img.mount():
try:
for (path, contents) in files:
Expand Down
14 changes: 1 addition & 13 deletions nova/virt/disk/mount.py
Expand Up @@ -30,13 +30,11 @@ class Mount(object):
to be called in that order.
"""

def __init__(self, image, mount_dir, partition=None,
disable_auto_fsck=False):
def __init__(self, image, mount_dir, partition=None):

# Input
self.image = image
self.partition = partition
self.disable_auto_fsck = disable_auto_fsck
self.mount_dir = mount_dir

# Output
Expand Down Expand Up @@ -84,16 +82,6 @@ def map_dev(self):
self.mapped_device = self.device
self.mapped = True

# This is an orthogonal operation
# which only needs to be done once
if self.disable_auto_fsck and self.mapped:
self.disable_auto_fsck = False
# attempt to set ext[234] so that it doesn't auto-fsck
_out, err = utils.trycmd('tune2fs', '-c', 0, '-i', 0,
self.mapped_device, run_as_root=True)
if err:
LOG.info(_('Failed to disable fs check: %s') % err)

return self.mapped

def unmap_dev(self):
Expand Down
5 changes: 1 addition & 4 deletions nova/virt/libvirt/connection.py
Expand Up @@ -1076,11 +1076,9 @@ def basepath(fname='', suffix=suffix):
if config_drive: # Should be True or None by now.
injection_path = basepath('disk.config')
img_id = 'config-drive'
disable_auto_fsck = False
else:
injection_path = basepath('disk')
img_id = inst.image_ref
disable_auto_fsck = True

for injection in ('metadata', 'key', 'net'):
if locals()[injection]:
Expand All @@ -1090,8 +1088,7 @@ def basepath(fname='', suffix=suffix):
try:
disk.inject_data(injection_path, key, net, metadata,
partition=target_partition,
use_cow=FLAGS.use_cow_images,
disable_auto_fsck=disable_auto_fsck)
use_cow=FLAGS.use_cow_images)

except Exception as e:
# This could be a windows image, or a vmdk format disk
Expand Down

0 comments on commit a8104eb

Please sign in to comment.