Proxmox Virtual Environment: qm showcmd (with examples)

Proxmox Virtual Environment: qm showcmd (with examples)

Introduction

The qm showcmd command in Proxmox Virtual Environment (PVE) allows users to view the command-line used to start a virtual machine (VM). This command can provide valuable debug information and help troubleshoot issues related to VM creation and startup. By using different options, users can customize the output format and retrieve information from specific snapshots. In this article, we will explore eight different use cases of the qm showcmd command, each with their own code example, motivation, explanation of arguments, and example output. Let’s dive in!

1. Show command-line for a specific virtual machine

qm showcmd 100

Motivation

When working with multiple VMs, it is often necessary to retrieve the command used to start a particular VM. This can be useful for documenting or sharing VM configurations or when troubleshooting startup issues specific to a VM.

Explanation

  • qm is the command used to interact with VMs in Proxmox VE.
  • showcmd is the specific subcommand used to display the command-line for a VM.
  • 100 represents the unique ID of the VM for which we want to view the command-line.

Example Output

/usr/bin/kvm -id 100 -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=serial0,path=/var/run/qemu-server/100.serial0,server,nowait' -device 'isa-serial,chardev=serial0' -vncunix '/var/run/qemu-server/100.vnc' -smbios 'type=1,uuid=de641210-dd24-47ad-add4-0e58d12e1a71' -no-reboot -boot 'menu=on,strict=on' -device 'piix3-usb-uhci,id=uhci,masterbus=pci.0,firstport=0,multifunction=on' -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' -cpu 'host,hidden=1' -m 2048 -machine 'pc-q35-2.10' -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' -realtime 'mlock=off' -smp '2,sockets=1,cores=2,maxcpus=2' -nodefaults -no-user-config -nodefconfig -rtc 'driftfix=slew,base=localtime' -global 'KVM-pit.lost_tick_policy=discard' -no-hpet -no-hvp -global 'PIIX4_PM.disable_s3=1' -global 'PIIX4_PM.disable_s4=1' -boot 'menu=on,reboot-timeout=10000,reboot-timeout=10000' -device 'ahci,id=sata0,bus=pci.0,addr=0x5' -drive 'if=none,id=drive-sata0-0-0,format=qcow2,file=/var/lib/vz/images/100/vm-100-disk-1.qcow2' -device 'virtio-blk-pci,drive=drive-sata0-0-0,id=sata0-0-0,bus=ahci.0,addr=0x0' -netdev 'type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' -device 'e1000,mac=DE:45:51:5E:8A:28,netdev=net0,bus=pci.0,addr=0x12' -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=serial0,path=/var/run/qemu-server/100.serial0,server,nowait' -device 'isa-serial,chardev=serial0'

The output shows the complete command used to start the VM with ID 100, including all necessary parameters and options.

2. Put each option on a new line to enhance human readability

qm showcmd --pretty true 100

Motivation

The default output of the qm showcmd command can be a long single line, making it difficult to read and understand. By using the --pretty option, we can improve the output’s visual layout by putting each option on a new line, enhancing human readability.

Explanation

  • --pretty is the option used to format the output of the qm showcmd command.
  • true is the argument for the --pretty option, indicating that the output should be formatted to enhance human readability.
  • 100 represents the VM ID for which we want to view the command-line.

Example Output

/usr/bin/kvm -id 100
  -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait'
  -mon 'chardev=qmp,mode=control'
  -chardev 'socket,id=serial0,path=/var/run/qemu-server/100.serial0,server,nowait'
  -device 'isa-serial,chardev=serial0'
  -vncunix '/var/run/qemu-server/100.vnc'
  -smbios 'type=1,uuid=de641210-dd24-47ad-add4-0e58d12e1a71'
  -no-reboot
  ...

The output is formatted with each option on a new line, making it easier to read and understand the command-line used to start the VM.

3. Fetch config values from a specific snapshot

qm showcmd --snapshot my_snapshot 100

Motivation

Snapshots in Proxmox VE allow users to save the state of a VM at a specific point in time. By using the --snapshot option with the qm showcmd command, we can retrieve the config values used during that specific snapshot. This can be helpful for comparing configurations or understanding the changes made since the snapshot was taken.

Explanation

  • --snapshot is the option used to specify the specific snapshot from which we want to fetch the config values.
  • my_snapshot represents the name of the snapshot for which we want to fetch the config values.
  • 100 represents the VM ID for which we want to view the command-line.

Example Output

/usr/bin/kvm -id 100 -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=serial0,path=/var/run/qemu-server/100.serial0,server,nowait' -device 'isa-serial,chardev=serial0' -vncunix '/var/run/qemu-server/100.vnc' -smbios 'type=1,uuid=de641210-dd24-47ad-add4-0e58d12e1a71' -no-reboot -boot 'menu=on,strict=on' -device 'piix3-usb-uhci,id=uhci,masterbus=pci.0,firstport=0,multifunction=on' -device 'usb-tablet,id=tablet,bus=uhci.0,port=1' -cpu 'host,hidden=1' -m 2048 -machine 'pc-q35-2.10' -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3' -realtime 'mlock=off' -smp '2,sockets=1,cores=2,maxcpus=2' -nodefaults -no-user-config -nodefconfig -rtc 'driftfix=slew,base=localtime' -global 'KVM-pit.lost_tick_policy=discard' -no-hpet -no-hvp -global 'PIIX4_PM.disable_s3=1' -global 'PIIX4_PM.disable_s4=1' -boot 'menu=on,reboot-timeout=10000,reboot-timeout=10000' -device 'ahci,id=sata0,bus=pci.0,addr=0x5' -drive 'if=none,id=drive-sata0-0-0,format=qcow2,file=/var/lib/vz/images/100/vm-100-disk-1.qcow2' -device 'virtio-blk-pci,drive=drive-sata0-0-0,id=sata0-0-0,bus=ahci.0,addr=0x0' -netdev 'type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on' -device 'e1000,mac=DE:45:51:5E:8A:28,netdev=net0,bus=pci.0,addr=0x12' -chardev 'socket,id=qmp,path=/var/run/qemu-server/100.qmp,server,nowait' -mon 'chardev=qmp,mode=control' -chardev 'socket,id=serial0,path=/var/run/qemu-server/100.serial0,server,nowait' -device 'isa-serial,chardev=serial0'

The output is the same as the previous example, as the snapshot name “my_snapshot” did not exist.

Related Posts

Updating Document Translations with po4a-updatepo (with examples)

Updating Document Translations with po4a-updatepo (with examples)

Updating a PO file according to the modification of its origin file po4a-updatepo --format text --master path/to/master.

Read More
How to use the command fdupes (with examples)

How to use the command fdupes (with examples)

fdupes is a command-line tool that helps in finding duplicate files within a given set of directories.

Read More
How to use the command "helm install" (with examples)

How to use the command "helm install" (with examples)

“Helm install” is a command used in the Helm package manager to install a Helm chart.

Read More