On Fri, Jun 07, 2019 at 12:00:56PM +0200, Fabiano Fidêncio wrote: > Instead of using "floppy" as the way to perform unattended installations > for Windoes, let's prefer using "cdrom" instead. Aren't there versions of windows which /only/ support "floppy", which would require us to preferentially use "cdrom" but fallback to "floppy" for older versions ? > The main reasons behind this change are: > - VMs using q35 may have floppy device disabled in some systems; > - We can drop mstools dependency; > > Generating the ISO depends on genisofs, tho. However, it's not a big > deal as genisofs is already a virt-manager dependency. > > Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> > --- > virt-manager.spec.in | 5 ---- > virtinst/{floppyinject.py => cdrominject.py} | 26 +++++++++++------ > virtinst/installer.py | 30 ++++++++++---------- > virtinst/unattended.py | 2 +- > 4 files changed, 33 insertions(+), 30 deletions(-) > rename virtinst/{floppyinject.py => cdrominject.py} (55%) > > diff --git a/virt-manager.spec.in b/virt-manager.spec.in > index b5f6979b..43e0c10b 100644 > --- a/virt-manager.spec.in > +++ b/virt-manager.spec.in > @@ -48,11 +48,6 @@ Requires: dconf > # no ambiguity. > Requires: vte291 > > -# Those two dependencies are needed in order to support unattended > -# installation for Windows guests. > -Requires: dosfstools > -Requires: mtools > - > # Weak dependencies for the common virt-manager usecase > Recommends: (libvirt-daemon-kvm or libvirt-daemon-qemu) > Recommends: libvirt-daemon-config-network > diff --git a/virtinst/floppyinject.py b/virtinst/cdrominject.py > similarity index 55% > rename from virtinst/floppyinject.py > rename to virtinst/cdrominject.py > index 05f91ee0..9dc6e20a 100644 > --- a/virtinst/floppyinject.py > +++ b/virtinst/cdrominject.py > @@ -6,11 +6,12 @@ > > import logging > import os > +import shutil > import subprocess > import tempfile > > > -def perform_floppy_injections(injections, scratchdir): > +def perform_cdrom_injections(injections, scratchdir): > """ > Insert files into the root directory of a floppy > """ > @@ -20,17 +21,24 @@ def perform_floppy_injections(injections, scratchdir): > tempdir = tempfile.mkdtemp(dir=scratchdir) > os.chmod(tempdir, 0o775) > > - img = os.path.join(tempdir, "unattended.img") > + tempfiles = [] > + iso = os.path.join(tempdir, "unattended.iso") > + for filename in injections: > + shutil.copy(filename, tempdir) > + > + tempfiles = os.listdir(tempdir) > > - cmd = ["mkfs.msdos", "-C", img, "1440"] > + cmd = ["mkisofs", > + "-o", iso, > + "-J", > + "-input-charset", "utf8", > + "-rational-rock", > + tempdir] > logging.debug("Running mkisofs: %s", cmd) > output = subprocess.check_output(cmd) > logging.debug("cmd output: %s", output) > > - for filename in injections: > - logging.debug("Copying %s to the floppy.", filename) > - cmd = ["mcopy", "-i", img, filename, "::"] > - output = subprocess.check_output(cmd) > - logging.debug("cmd output: %s", output) > + for f in tempfiles: > + os.unlink(os.path.join(tempdir, f)) > > - return img > + return iso > diff --git a/virtinst/installer.py b/virtinst/installer.py > index 45caf930..e6524708 100644 > --- a/virtinst/installer.py > +++ b/virtinst/installer.py > @@ -15,7 +15,7 @@ from .devices import DeviceDisk > from .domain import DomainOs > from .osdict import OSDB, OsMedia > from .installertreemedia import InstallerTreeMedia > -from .floppyinject import perform_floppy_injections > +from .cdrominject import perform_cdrom_injections > from . import unattended > from . import util > > @@ -51,7 +51,7 @@ class Installer(object): > self._install_kernel = None > self._install_initrd = None > self._install_cdrom_device_added = False > - self._install_floppy_device = False > + self._unattended_install_cdrom_device = None > self._unattended_files = [] > self._defaults_are_set = False > self._unattended_data = None > @@ -119,25 +119,25 @@ class Installer(object): > disk.sync_path_props() > break > > - def _add_install_floppy_device(self, guest, location): > - if self._install_floppy_device: > + def _add_unattended_install_cdrom_device(self, guest, location): > + if self._unattended_install_cdrom_device: > return > dev = DeviceDisk(self.conn) > - dev.device = dev.DEVICE_FLOPPY > + dev.device = dev.DEVICE_CDROM > dev.path = location > dev.sync_path_props() > dev.validate() > dev.set_defaults(guest) > - self._install_floppy_device = dev > - guest.add_device(self._install_floppy_device) > + self._unattended_install_cdrom_device = dev > + guest.add_device(self._unattended_install_cdrom_device) > > - def _remove_install_floppy_device(self, guest): > + def _remove_unattended_install_cdrom_device(self, guest): > dummy = guest > - if not self._install_floppy_device: > + if not self._unattended_install_cdrom_device: > return > > - self._install_floppy_device.path = None > - self._install_floppy_device.sync_path_props() > + self._unattended_install_cdrom_device.path = None > + self._unattended_install_cdrom_device.sync_path_props() > > def _cleanup_unattended_files(self): > for f in self._unattended_files: > @@ -225,10 +225,10 @@ class Installer(object): > logging.debug("Generated script contents:\n%s", > open(path).read()) > > - floppy = perform_floppy_injections([path], util.get_cache_dir()) > - self._add_install_floppy_device(guest, floppy) > + iso = perform_cdrom_injections([path], util.get_cache_dir()) > + self._add_unattended_install_cdrom_device(guest, iso) > > - self._unattended_files.extend([path, floppy]) > + self._unattended_files.extend([path, iso]) > > def _cleanup(self, guest): > if self._treemedia: > @@ -377,7 +377,7 @@ class Installer(object): > return ret > finally: > self._remove_install_cdrom_media(guest) > - self._remove_install_floppy_device(guest) > + self._remove_unattended_install_cdrom_device(guest) > self._finish_get_install_xml(guest, data) > > def _build_xml(self, guest, meter): > diff --git a/virtinst/unattended.py b/virtinst/unattended.py > index 11de2fed..4779de93 100644 > --- a/virtinst/unattended.py > +++ b/virtinst/unattended.py > @@ -251,7 +251,7 @@ def prepare_install_script(guest, unattended_data, url=None, os_media=None): > > # For all tree based installations we're going to perform initrd injection > # and install the systems via network. > - injection_method = "floppy" if guest.osinfo.is_windows() else "initrd" > + injection_method = "cdrom" if guest.osinfo.is_windows() else "initrd" > script.set_preferred_injection_method(injection_method) > > installationsource = _get_installation_source(os_media) > -- > 2.21.0 > > _______________________________________________ > virt-tools-list mailing list > virt-tools-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/virt-tools-list Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :| _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list