我正在运行这个命令
virt-sysprep -v -x -c qemu+ssh://user@IPADDRESS/system -d REMOTEVM --hostname REMOTEVM --root-password password:123456 --upload /home/www/interfaces:/etc/network/interfaces
但我收到这个错误
virt-sysprep -v -x -c qemu+ssh://user@ipaddress/system -d REMOTEVM --hostname REMOTEVM --root-password password:123456 --upload /home/www/interfaces:/etc/network/interfaces
[ 0.0] Examining the guest ...
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
libguestfs: trace: set_network false
libguestfs: trace: set_network = 0
libguestfs: trace: add_domain "REMOTEVM" "libvirturi:qemu+ssh://user@ipaddress/system" "readonly:false" "allowuuid:true" "readonlydisk:ignore" "discard:besteffort"
libguestfs: opening libvirt handle: URI = qemu+ssh://user@ipaddress/system, auth = default+wrapper, flags = 0
libguestfs: successfully opened libvirt handle: conn = 0x55d71ad4a520
libguestfs: trace: add_libvirt_dom (virDomainPtr)0x55d71ad4e9d0 "readonlydisk:ignore" "discard:besteffort"
libguestfs: original domain XML:\n<domain type='kvm'>\n <name>REMOTEVM</name>\n <uuid>c23b6f17-50f4-43e2-9003-463366951382</uuid>\n <memory unit='KiB'>1048576</memory>\n <currentMemory unit='KiB'>1048576</currentMemory>\n <vcpu placement='static'>1</vcpu>\n <os>\n <type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type>\n <boot dev='hd'/>\n </os>\n <features>\n <acpi/>\n <apic/>\n <vmport state='off'/>\n </features>\n <cpu mode='custom' match='exact'>\n <model fallback='allow'>IvyBridge</model>\n </cpu>\n <clock offset='utc'>\n <timer name='rtc' tickpolicy='catchup'/>\n <timer name='pit' tickpolicy='delay'/>\n <timer name='hpet' present='no'/>\n </clock>\n <on_poweroff>destroy</on_poweroff>\n <on_reboot>restart</on_reboot>\n <on_crash>destroy</on_crash>\n <pm>\n <suspend-to-mem enabled='no'/>\n <suspend-to-disk enabled='no'/>\n </pm>\n <devices>\n <emulator>/usr/bin/kvm-spice</emulator>\n <disk type='file' device='disk'>\n <driver name='qemu' type='qcow2'/>\n <source file='/var/lib/libvirt/images/REMOTEVM.qcow2'/>\n <target dev='vda' bus='virtio'/>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>\n </disk>\n <controller type='usb' index='0' model='ich9-ehci1'>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>\n </controller>\n <controller type='usb' index='0' model='ich9-uhci1'>\n <master startport='0'/>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>\n </controller>\n <controller type='usb' index='0' model='ich9-uhci2'>\n <master startport='2'/>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>\n </controller>\n <controller type='usb' index='0' model='ich9-uhci3'>\n <master startport='4'/>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>\n </controller>\n <controller type='pci' index='0' model='pci-root'/>\n <controller type='virtio-serial' index='0'>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>\n </controller>\n <interface type='bridge'>\n <mac address='52:54:00:83:b3:b0'/>\n <source bridge='br0'/>\n <model type='virtio'/>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n </interface>\n <serial type='pty'>\n <target port='0'/>\n </serial>\n <console type='pty'>\n <target type='serial' port='0'/>\n </console>\n <channel type='spicevmc'>\n <target type='virtio' name='com.redhat.spice.0'/>\n <address type='virtio-serial' controller='0' bus='0' port='1'/>\n </channel>\n <input type='tablet' bus='usb'/>\n <input type='mouse' bus='ps2'/>\n <input type='keyboard' bus='ps2'/>\n <graphics type='spice' autoport='yes'/>\n <sound model='ich6'>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>\n </sound>\n <video>\n <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>\n </video>\n <redirdev bus='usb' type='spicevmc'>\n </redirdev>\n <redirdev bus='usb' type='spicevmc'>\n </redirdev>\n <memballoon model='virtio'>\n <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>\n </memballoon>\n </devices>\n</domain>\n
libguestfs: trace: clear_backend_setting "internal_libvirt_norelabel_disks"
libguestfs: trace: clear_backend_setting = 0
libguestfs: disk[0]: filename: /var/lib/libvirt/images/REMOTEVM.qcow2
libguestfs: trace: add_drive "/var/lib/libvirt/images/REMOTEVM.qcow2" "readonly:false" "format:qcow2" "discard:besteffort"
libguestfs: trace: add_drive = -1 (error)
libguestfs: trace: add_libvirt_dom = -1 (error)
libguestfs: trace: add_domain = -1 (error)
virt-sysprep: error: libguestfs error:
/var/lib/libvirt/images/REMOTEVM.qcow2: No such file or directory
libguestfs: trace: close
libguestfs: closing guestfs handle 0x55d71ad48a00 (state 0)
但如果我 ssh 进入远程机器并运行命令,它就可以-c qemu+ssh://user@IPADDRESS/system
工作
答案1
显然这个问题无法修复。 https://bugzilla.redhat.com/show_bug.cgi?id=1596963
不幸的是,libvirt 没有为我们提供远程访问磁盘的方法,因此如果您连接到远程 libvirt,它仍会尝试将磁盘像本地文件一样加载。
这基本上是 libvirt 的设计问题,例如尝试简单地执行:virsh -c qemu+ssh://user@ipaddress/system dumpxml REMOTEVM 并查看返回的磁盘路径。(实际上情况比这更糟,因为我们无法检测 libvirt 连接是本地的还是远程的,因此例如 @localhost 可以工作)。
恐怕如果您想要对远程磁盘进行系统准备,您将必须找到一种方法来在本地使用磁盘安装文件系统(例如,通过 NFS 共享 /var/lib/libvirt/images)或找到另一种方法来导出文件系统(例如,NBD)或只是在远程机器上运行 virt-sysprep。