KVM-TEST: Use cdrom for Linux guests in unattended_install
PATCH 1/1 KVM-TEST: Use cdrom for Linux guests in unattended_install
Bug 615839 - kernel panic when install guest with -fda
There exists a bug of floppy driver, it blocked our installation tests. So replace floppy with cdrom for Linux guestsin unattended_install.
Signed-off-by Amos Kong <[email protected]>
---
0 files changed, 0 insertions(+), 0 deletions(-)
client/tests/kvm/scripts/unattended.py +70 -53
@@ -81,8 +81,14 @@ class UnattendedInstall(object): self.kernel_args = os.environ.get('KVM_TEST_kernel_args', '') self.finish_program = os.environ.get('KVM_TEST_finish_program', '') - cdrom_iso = os.environ.get('KVM_TEST_cdrom_cd1') self.unattended_file = os.environ.get('KVM_TEST_unattended_file') + cdrom_cd1 = os.environ.get('KVM_TEST_cdrom_cd1', '') + cdrom_cd2 = os.environ.get('KVM_TEST_cdrom_cd2', '') + self.cd1_iso = os.path.join(kvm_test_dir, cdrom_cd1) + self.cd2_iso = os.path.join(kvm_test_dir, cdrom_cd2) + cd1_dir = os.path.dirname(self.cd1_iso) + if not os.path.isdir(cd1_dir): + os.makedirs(cd1_dir) install_virtio = os.environ.get('KVM_TEST_install_virtio', 'no') if install_virtio == 'yes':
@@ -120,16 +126,19 @@ class UnattendedInstall(object): self.qemu_img_bin = os.environ.get('KVM_TEST_qemu_img_binary') if not os.path.isabs(self.qemu_img_bin): self.qemu_img_bin = os.path.join(kvm_test_dir, self.qemu_img_bin) - self.cdrom_iso = os.path.join(kvm_test_dir, cdrom_iso) - self.floppy_mount = tempfile.mkdtemp(prefix='floppy_', dir='/tmp') - self.cdrom_mount = tempfile.mkdtemp(prefix='cdrom_', dir='/tmp') + + self.cd1_mount = tempfile.mkdtemp(prefix='cd1_', dir='/tmp') + self.cd2_mount = tempfile.mkdtemp(prefix='cd2_', dir='/tmp') + self.boot_img_mount = tempfile.mkdtemp(prefix='boot_img_', dir='/tmp') self.nfs_mount = tempfile.mkdtemp(prefix='nfs_', dir='/tmp') - floppy_name = os.environ['KVM_TEST_floppy'] + + floppy_name = os.environ.get('KVM_TEST_floppy', '') self.floppy_img = os.path.join(kvm_test_dir, floppy_name) floppy_dir = os.path.dirname(self.floppy_img) if not os.path.isdir(floppy_dir): os.makedirs(floppy_dir) + self.pxe_dir = os.environ.get('KVM_TEST_pxe_dir', '') self.pxe_image = os.environ.get('KVM_TEST_pxe_image', '') self.pxe_initrd = os.environ.get('KVM_TEST_pxe_initrd', '')
@@ -162,7 +171,7 @@ class UnattendedInstall(object): path_list = glob.glob('*') for path in path_list: src = os.path.join(self.virtio_floppy_mount, path) - dst = os.path.join(self.floppy_mount, path) + dst = os.path.join(self.boot_img_mount, path) if os.path.isdir(path): shutil.copytree(src, dst) elif os.path.isfile(path):
@@ -205,7 +214,7 @@ class UnattendedInstall(object): 4) Re-write the config file to the disk """ self.copy_virtio_drivers_floppy() - txtsetup_oem = os.path.join(self.floppy_mount, 'txtsetup.oem') + txtsetup_oem = os.path.join(self.boot_img_mount, 'txtsetup.oem') if not os.path.isfile(txtsetup_oem): raise SetupError('File txtsetup.oem not found on the install ' 'floppy. Please verify if your floppy virtio '
@@ -223,37 +232,38 @@ class UnattendedInstall(object): fp.close() - def create_boot_floppy(self): + def create_boot_img(self): """ - Prepares a boot floppy by creating a floppy image file, mounting it and - copying an answer file (kickstarts for RH based distros, answer files - for windows) to it. After that the image is umounted. + Prepares a boot floppy/iso image by creating a floppy/iso image file, + it contains an answer file (kickstarts for RH based distros, answer + files for windows). After that the image is umounted. """ - print "Creating boot floppy" - - if os.path.exists(self.floppy_img): - os.remove(self.floppy_img) - - c_cmd = '%s create -f raw %s 1440k' % (self.qemu_img_bin, - self.floppy_img) - if os.system(c_cmd): - raise SetupError('Could not create floppy image.') - - f_cmd = 'mkfs.msdos -s 1 %s' % self.floppy_img - if os.system(f_cmd): - raise SetupError('Error formatting floppy image.') - try: - m_cmd = 'mount -o loop,rw %s %s' % (self.floppy_img, - self.floppy_mount) - if os.system(m_cmd): - raise SetupError('Could not mount floppy image.') + if self.floppy_img: + print "Creating boot floppy" + + if os.path.exists(self.floppy_img): + os.remove(self.floppy_img) + c_cmd = '%s create -f raw %s 1440k' % (self.qemu_img_bin, + self.floppy_img) + if os.system(c_cmd): + raise SetupError('Could not create floppy image.') + + m_cmd = 'mount -o loop %s %s' % (self.floppy_img, self.boot_img_mount) + if os.system(m_cmd): + raise SetupError('Could not mount floppy image.') + + f_cmd = 'mkfs.msdos -s 1 %s' % self.floppy_img + if os.system(f_cmd): + raise SetupError('Error formatting floppy image.') + else: + print "Creating boot cdrom iso" if self.unattended_file.endswith('.sif'): dest_fname = 'winnt.sif' setup_file = 'winnt.bat' setup_file_path = os.path.join(self.unattended_dir, setup_file) - setup_file_dest = os.path.join(self.floppy_mount, setup_file) + setup_file_dest = os.path.join(self.boot_img_mount, setup_file) shutil.copyfile(setup_file_path, setup_file_dest) if self.install_virtio: self.setup_virtio_win2003()
@@ -271,7 +281,7 @@ class UnattendedInstall(object): # SUSE autoyast install dest_fname = "autoinst.xml" - dest = os.path.join(self.floppy_mount, dest_fname) + dest = os.path.join(self.boot_img_mount, dest_fname) # Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey # provided for this test and replace the KVM_TEST_MEDIUM with
@@ -346,20 +356,26 @@ class UnattendedInstall(object): if self.finish_program: dest_fname = os.path.basename(self.finish_program) - dest = os.path.join(self.floppy_mount, dest_fname) + dest = os.path.join(self.boot_img_mount, dest_fname) shutil.copyfile(self.finish_program, dest) - finally: - u_cmd = 'umount %s' % self.floppy_mount - if os.system(u_cmd): - raise SetupError('Could not unmount floppy at %s.' % - self.floppy_mount) - self.cleanup(self.floppy_mount) - - os.chmod(self.floppy_img, 0755) - - print "Boot floppy created successfuly" + if not self.floppy_img: + m_cmd = 'mkisofs -o %s %s/*' % (self.cd1_iso, + self.boot_img_mount) + if os.system(m_cmd): + raise SetupError('Could not create cdrom iso.') + finally: + if self.floppy_img: + u_cmd = 'umount %s' % self.boot_img_mount + if os.system(u_cmd): + raise SetupError('Could not unmount floppy at %s.' % + self.boot_img_mount) + self.cleanup(self.boot_img_mount) + print "Boot floppy created successfuly" + else: + os.chmod(self.cd1_iso, 0755) + print "Boot cdrom iso created successfuly" def setup_pxe_boot(self): """
@@ -388,13 +404,13 @@ class UnattendedInstall(object): shutil.copyfile(pxe_file, pxe_dest) try: - m_cmd = 'mount -t iso9660 -v -o loop,ro %s %s' % (self.cdrom_iso, - self.cdrom_mount) + m_cmd = 'mount -t iso9660 -v -o loop,ro %s %s' % (self.cd1_iso, + self.cd2_mount) if os.system(m_cmd): raise SetupError('Could not mount CD image %s.' % - self.cdrom_iso) + self.cd1_iso) - pxe_dir = os.path.join(self.cdrom_mount, self.pxe_dir) + pxe_dir = os.path.join(self.cd2_mount, self.pxe_dir) pxe_image = os.path.join(pxe_dir, self.pxe_image) pxe_initrd = os.path.join(pxe_dir, self.pxe_initrd)
@@ -415,11 +431,11 @@ class UnattendedInstall(object): shutil.copyfile(pxe_initrd, tftp_initrd) finally: - u_cmd = 'umount %s' % self.cdrom_mount + u_cmd = 'umount %s' % self.cd2_mount if os.system(u_cmd): raise SetupError('Could not unmount CD at %s.' % - self.cdrom_mount) - self.cleanup(self.cdrom_mount) + self.cd2_mount) + self.cleanup(self.cd2_mount) pxe_config_dir = os.path.join(self.tftp_root, 'pxelinux.cfg') if not os.path.isdir(pxe_config_dir):
@@ -511,11 +527,12 @@ class UnattendedInstall(object): print "Variables set:" print " medium: " + str(self.medium) print " qemu_img_bin: " + str(self.qemu_img_bin) - print " cdrom iso: " + str(self.cdrom_iso) + print " cd1_iso: " + str(self.cd1_iso) + print " cd2_iso: " + str(self.cd2_iso) print " unattended_file: " + str(self.unattended_file) print " kernel_args: " + str(self.kernel_args) print " tftp_root: " + str(self.tftp_root) - print " floppy_mount: " + str(self.floppy_mount) + print " boot_img_mount: " + str(self.boot_img_mount) print " floppy_img: " + str(self.floppy_img) print " finish_program: " + str(self.finish_program) print " pxe_dir: " + str(self.pxe_dir)
@@ -528,8 +545,8 @@ class UnattendedInstall(object): print " nfs_dir: " + str(self.nfs_dir) print " nfs_mount: " + str(self.nfs_mount) - if self.unattended_file and self.floppy_img is not None: - self.create_boot_floppy() + if self.unattended_file and self.cd1_iso is not None: + self.create_boot_img() if self.medium == "cdrom": if self.tftp_root: self.setup_pxe_boot()
client/tests/kvm/tests_base.cfg.sample +46 -42
349 lines not on this page · raw message
PATCH v2 1/1 KVM-TEST: Use cdrom for Linux guests in unattended_install
Bug 615839 - kernel panic when install guest with -fda
There exists a bug of floppy driver, it blocked our installation tests. So replace floppy with cdrom for Linux guestsin unattended_install.
Changes from v1:
- Format floppy before mount
- Mount install ISO to self.cd2_iso
Signed-off-by Amos Kong <[email protected]>
--- client/tests/kvm/scripts/unattended.py | 127 ++++++++++++++++++-------------- client/tests/kvm/tests_base.cfg.sample | 88 ++++++++++++---------- 2 files changed, 119 insertions(+), 96 deletions(-)
client/tests/kvm/scripts/unattended.py +73 -54
@@ -81,8 +81,14 @@ class UnattendedInstall(object): self.kernel_args = os.environ.get('KVM_TEST_kernel_args', '') self.finish_program = os.environ.get('KVM_TEST_finish_program', '') - cdrom_iso = os.environ.get('KVM_TEST_cdrom_cd1') self.unattended_file = os.environ.get('KVM_TEST_unattended_file') + cdrom_cd1 = os.environ.get('KVM_TEST_cdrom_cd1', '') + cdrom_cd2 = os.environ.get('KVM_TEST_cdrom_cd2', '') + self.cd1_iso = os.path.join(kvm_test_dir, cdrom_cd1) + self.cd2_iso = os.path.join(kvm_test_dir, cdrom_cd2) + cd1_dir = os.path.dirname(self.cd1_iso) + if not os.path.isdir(cd1_dir): + os.makedirs(cd1_dir) install_virtio = os.environ.get('KVM_TEST_install_virtio', 'no') if install_virtio == 'yes':
@@ -120,15 +126,19 @@ class UnattendedInstall(object): self.qemu_img_bin = os.environ.get('KVM_TEST_qemu_img_binary') if not os.path.isabs(self.qemu_img_bin): self.qemu_img_bin = os.path.join(kvm_test_dir, self.qemu_img_bin) - self.cdrom_iso = os.path.join(kvm_test_dir, cdrom_iso) - self.floppy_mount = tempfile.mkdtemp(prefix='floppy_', dir='/tmp') - self.cdrom_mount = tempfile.mkdtemp(prefix='cdrom_', dir='/tmp') + + self.cd1_mount = tempfile.mkdtemp(prefix='cd1_', dir='/tmp') + self.cd2_mount = tempfile.mkdtemp(prefix='cd2_', dir='/tmp') + self.boot_img_mount = tempfile.mkdtemp(prefix='boot_img_', dir='/tmp') self.nfs_mount = tempfile.mkdtemp(prefix='nfs_', dir='/tmp') - floppy_name = os.environ['KVM_TEST_floppy'] - self.floppy_img = os.path.join(kvm_test_dir, floppy_name) - floppy_dir = os.path.dirname(self.floppy_img) - if not os.path.isdir(floppy_dir): - os.makedirs(floppy_dir) + + floppy_name = os.environ.get('KVM_TEST_floppy', '') + self.floppy_img = '' + if floppy_name: + self.floppy_img = os.path.join(kvm_test_dir, floppy_name) + floppy_dir = os.path.dirname(self.floppy_img) + if not os.path.isdir(floppy_dir): + os.makedirs(floppy_dir) self.pxe_dir = os.environ.get('KVM_TEST_pxe_dir', '') self.pxe_image = os.environ.get('KVM_TEST_pxe_image', '')
@@ -162,7 +172,7 @@ class UnattendedInstall(object): path_list = glob.glob('*') for path in path_list: src = os.path.join(self.virtio_floppy_mount, path) - dst = os.path.join(self.floppy_mount, path) + dst = os.path.join(self.boot_img_mount, path) if os.path.isdir(path): shutil.copytree(src, dst) elif os.path.isfile(path):
@@ -205,7 +215,7 @@ class UnattendedInstall(object): 4) Re-write the config file to the disk """ self.copy_virtio_drivers_floppy() - txtsetup_oem = os.path.join(self.floppy_mount, 'txtsetup.oem') + txtsetup_oem = os.path.join(self.boot_img_mount, 'txtsetup.oem') if not os.path.isfile(txtsetup_oem): raise SetupError('File txtsetup.oem not found on the install ' 'floppy. Please verify if your floppy virtio '
@@ -223,37 +233,39 @@ class UnattendedInstall(object): fp.close() - def create_boot_floppy(self): + def create_boot_img(self): """ - Prepares a boot floppy by creating a floppy image file, mounting it and - copying an answer file (kickstarts for RH based distros, answer files - for windows) to it. After that the image is umounted. + Prepares a boot floppy/iso image by creating a floppy/iso image file, + it contains an answer file (kickstarts for RH based distros, answer + files for windows). After that the image is umounted. """ - print "Creating boot floppy" + try: + if self.floppy_img: + print "Creating boot floppy" - if os.path.exists(self.floppy_img): - os.remove(self.floppy_img) + if os.path.exists(self.floppy_img): + os.remove(self.floppy_img) + c_cmd = '%s create -f raw %s 1440k' % (self.qemu_img_bin, + self.floppy_img) + if os.system(c_cmd): + raise SetupError('Could not create floppy image.') - c_cmd = '%s create -f raw %s 1440k' % (self.qemu_img_bin, - self.floppy_img) - if os.system(c_cmd): - raise SetupError('Could not create floppy image.') + f_cmd = 'mkfs.msdos -s 1 %s' % self.floppy_img + if os.system(f_cmd): + raise SetupError('Error formatting floppy image.') - f_cmd = 'mkfs.msdos -s 1 %s' % self.floppy_img - if os.system(f_cmd): - raise SetupError('Error formatting floppy image.') + m_cmd = 'mount -o loop %s %s' % (self.floppy_img, self.boot_img_mount) + if os.system(m_cmd): + raise SetupError('Could not mount floppy image.') - try: - m_cmd = 'mount -o loop,rw %s %s' % (self.floppy_img, - self.floppy_mount) - if os.system(m_cmd): - raise SetupError('Could not mount floppy image.') + else: + print "Creating boot cdrom iso" if self.unattended_file.endswith('.sif'): dest_fname = 'winnt.sif' setup_file = 'winnt.bat' setup_file_path = os.path.join(self.unattended_dir, setup_file) - setup_file_dest = os.path.join(self.floppy_mount, setup_file) + setup_file_dest = os.path.join(self.boot_img_mount, setup_file) shutil.copyfile(setup_file_path, setup_file_dest) if self.install_virtio: self.setup_virtio_win2003()
@@ -271,7 +283,7 @@ class UnattendedInstall(object): # SUSE autoyast install dest_fname = "autoinst.xml" - dest = os.path.join(self.floppy_mount, dest_fname) + dest = os.path.join(self.boot_img_mount, dest_fname) # Replace KVM_TEST_CDKEY (in the unattended file) with the cdkey # provided for this test and replace the KVM_TEST_MEDIUM with
@@ -346,20 +358,26 @@ class UnattendedInstall(object): if self.finish_program: dest_fname = os.path.basename(self.finish_program) - dest = os.path.join(self.floppy_mount, dest_fname) + dest = os.path.join(self.boot_img_mount, dest_fname) shutil.copyfile(self.finish_program, dest) - finally: - u_cmd = 'umount %s' % self.floppy_mount - if os.system(u_cmd): - raise SetupError('Could not unmount floppy at %s.' % - self.floppy_mount) - self.cleanup(self.floppy_mount) - - os.chmod(self.floppy_img, 0755) - - print "Boot floppy created successfuly" + if not self.floppy_img: + m_cmd = 'mkisofs -o %s %s/*' % (self.cd1_iso, + self.boot_img_mount) + if os.system(m_cmd): + raise SetupError('Could not create cdrom iso.') + finally: + if self.floppy_img: + u_cmd = 'umount %s' % self.boot_img_mount + if os.system(u_cmd): + raise SetupError('Could not unmount floppy at %s.' % + self.boot_img_mount) + self.cleanup(self.boot_img_mount) + os.chmod(self.floppy_img, 0755) + print "Boot floppy created successfuly" + else: + print "Boot cdrom iso created successfuly" def setup_pxe_boot(self): """
@@ -388,13 +406,13 @@ class UnattendedInstall(object): shutil.copyfile(pxe_file, pxe_dest) try: - m_cmd = 'mount -t iso9660 -v -o loop,ro %s %s' % (self.cdrom_iso, - self.cdrom_mount) + m_cmd = 'mount -t iso9660 -v -o loop,ro %s %s' % (self.cd2_iso, + self.cd2_mount) if os.system(m_cmd): raise SetupError('Could not mount CD image %s.' % - self.cdrom_iso) + self.cd2_iso) - pxe_dir = os.path.join(self.cdrom_mount, self.pxe_dir) + pxe_dir = os.path.join(self.cd2_mount, self.pxe_dir) pxe_image = os.path.join(pxe_dir, self.pxe_image) pxe_initrd = os.path.join(pxe_dir, self.pxe_initrd)
@@ -415,11 +433,11 @@ class UnattendedInstall(object): shutil.copyfile(pxe_initrd, tftp_initrd) finally: - u_cmd = 'umount %s' % self.cdrom_mount + u_cmd = 'umount %s' % self.cd2_mount if os.system(u_cmd): raise SetupError('Could not unmount CD at %s.' % - self.cdrom_mount) - self.cleanup(self.cdrom_mount) + self.cd2_mount) + self.cleanup(self.cd2_mount) pxe_config_dir = os.path.join(self.tftp_root, 'pxelinux.cfg') if not os.path.isdir(pxe_config_dir):
@@ -511,11 +529,12 @@ class UnattendedInstall(object): print "Variables set:" print " medium: " + str(self.medium) print " qemu_img_bin: " + str(self.qemu_img_bin) - print " cdrom iso: " + str(self.cdrom_iso) + print " cd1_iso: " + str(self.cd1_iso) + print " cd2_iso: " + str(self.cd2_iso) print " unattended_file: " + str(self.unattended_file) print " kernel_args: " + str(self.kernel_args) print " tftp_root: " + str(self.tftp_root) - print " floppy_mount: " + str(self.floppy_mount) + print " boot_img_mount: " + str(self.boot_img_mount) print " floppy_img: " + str(self.floppy_img) print " finish_program: " + str(self.finish_program) print " pxe_dir: " + str(self.pxe_dir)
@@ -528,8 +547,8 @@ class UnattendedInstall(object): print " nfs_dir: " + str(self.nfs_dir) print " nfs_mount: " + str(self.nfs_mount) - if self.unattended_file and self.floppy_img is not None: - self.create_boot_floppy() + if self.unattended_file and self.cd1_iso is not None: + self.create_boot_img() if self.medium == "cdrom": if self.tftp_root: self.setup_pxe_boot()
client/tests/kvm/tests_base.cfg.sample +46 -42
349 lines not on this page · raw message