Virtualization

Virsh 無法檢測到我的新虛擬機

  • September 2, 2019

我有一個來自舊作業系統的 *.qcow2 映像,它包含 Windows 10。然後我將它複製到新作業系統並嘗試安裝它。我按照這裡寫的方法“如何從 virsh 中的現有基礎映像創建新域”。

但是我的虛擬機沒有從 virsh 中出現?(virsh list –all) 那麼如何讓 virsh 來檢測我的新虛擬機呢?或者,如果 virsh 無法檢測到,我該如何從命令行執行我的虛擬機?

以下是我在終端視窗中執行的一些命令:

$ sudo virt-sysprep -a /home/vm-images/win10.qcow2 
[sudo] password for ita: 
[   0.0] Examining the guest ...
[   4.9] Performing "abrt-data" ...
[   4.9] Performing "backup-files" ...
[  27.3] Performing "bash-history" ...
[  27.3] Performing "blkid-tab" ...
[  27.3] Performing "crash-data" ...
[  27.3] Performing "cron-spool" ...
[  27.3] Performing "dhcp-client-state" ...
[  27.4] Performing "dhcp-server-state" ...
[  27.4] Performing "dovecot-data" ...
[  27.4] Performing "logfiles" ...
[  27.4] Performing "machine-id" ...
[  27.4] Performing "mail-spool" ...
[  27.4] Performing "net-hostname" ...
[  27.5] Performing "net-hwaddr" ...
[  27.5] Performing "pacct-log" ...
[  27.5] Performing "package-manager-cache" ...
[  27.6] Performing "pam-data" ...
[  27.6] Performing "passwd-backups" ...
[  27.6] Performing "puppet-data-log" ...
[  27.6] Performing "rh-subscription-manager" ...
[  27.7] Performing "rhn-systemid" ...
[  27.7] Performing "rpm-db" ...
[  27.7] Performing "samba-db-log" ...
[  27.7] Performing "script" ...
[  27.7] Performing "smolt-uuid" ...
[  27.7] Performing "ssh-hostkeys" ...
[  27.8] Performing "ssh-userdir" ...
[  27.8] Performing "sssd-db-log" ...
[  27.8] Performing "tmp-files" ...
[  27.8] Performing "udev-persistent-net" ...
[  27.9] Performing "utmp" ...
[  27.9] Performing "yum-uuid" ...
[  27.9] Performing "customize" ...
[  27.9] Setting a random seed
virt-sysprep: warning: random seed could not be set for this type of guest
[  28.2] Performing "lvm-uuids" ...
$ virt-install -n windows-10 --connect=qemu:///system --description "Windows 10" --os-type=win10 --ram=2048 --vcpus=1 --disk path=/home/vm-images/win10.qcow2,bus=virtio,size=12 --network default --boot hd

Starting install...
Domain creation completed.
You can restart your domain by running:
 virsh --connect qemu:///system start windows-10
$ virsh list --all
Id   Name   State
--------------------

您忘記了virsh命令行選項--connect qemu:///system

因為您沒有以 root 身份執行 virsh,所以它預設為qemu:///session,它只顯示在您的使用者帳戶下執行的虛擬機。

引用自:https://serverfault.com/questions/981527