Similar to perform_initrd_injections(), which is used by Linux(es) unattended installations, perform_floppy_injections() is going to be used by Windows(es) unattended installations. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- virt-manager.spec.in | 5 +++++ virtinst/floppyinject.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 virtinst/floppyinject.py diff --git a/virt-manager.spec.in b/virt-manager.spec.in index 7e581833..37ea7a52 100644 --- a/virt-manager.spec.in +++ b/virt-manager.spec.in @@ -48,6 +48,11 @@ 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/floppyinject.py new file mode 100644 index 00000000..2edf2f43 --- /dev/null +++ b/virtinst/floppyinject.py @@ -0,0 +1,34 @@ +# +# Copyright 2019 Red Hat, Inc. +# +# This work is licensed under the GNU GPLv2 or later. +# See the COPYING file in the top-level directory. + +import logging +import os +import subprocess +import tempfile + + +def perform_floppy_injections(injections, scratchdir): + """ + Insert files into the root directory of a floppy + """ + if not injections: + return + + tempdir = tempfile.mkdtemp(dir=scratchdir) + os.chmod(tempdir, 0o775) + + img = os.path.join(tempdir, "unattended.img") + + cmd = ["mkfs.msdos", "-C", img, "1440"] + logging.debug("Running mkisofs: %s", cmd) + output = subprocess.check_output(cmd) + + for filename in injections: + logging.debug("Copying %s to the floppy.", filename) + cmd = ["mcopy", "-i", img, filename, "::"] + output = subprocess.check_output(cmd) + + return img -- 2.20.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list