[SOLVED] VM configuration from host

richardk

Member
Jul 21, 2020
8
0
6
39
All,

I am looking for how to configure VM hardware from the host's shell for scripting purposes. I'm running release 7.2-3.

For example: add/remove VM network adaptor, set VM static IP/MAC, change hostname, etc. etc..

Thanks in advance!
 
everything is handled via "qm" or "pvesh". Use "man qm" for more information or search the web:

Code:
root@proxmox-1:~# qm
ERROR: no command specified
USAGE: qm <COMMAND> [ARGS] [OPTIONS]

       qm cloudinit dump <vmid> <type>

       qm guest cmd <vmid> <command>
       qm guest exec-status <vmid> <pid>
       qm guest passwd <vmid> <username> [OPTIONS]
       qm guest exec <vmid> [<extra-args>] [OPTIONS]

       qm clone <vmid> <newid> [OPTIONS]
       qm config <vmid> [OPTIONS]
       qm create <vmid> [OPTIONS]
       qm delsnapshot <vmid> <snapname> [OPTIONS]
       qm destroy <vmid> [OPTIONS]
       qm list  [OPTIONS]
       qm listsnapshot <vmid>
       qm migrate <vmid> <target> [OPTIONS]
       qm move_disk <vmid> <disk> <storage> [OPTIONS]
       qm pending <vmid>
       qm reboot <vmid> [OPTIONS]
       qm reset <vmid> [OPTIONS]
       qm resize <vmid> <disk> <size> [OPTIONS]
       qm resume <vmid> [OPTIONS]
       qm rollback <vmid> <snapname>
       qm sendkey <vmid> <key> [OPTIONS]
       qm set <vmid> [OPTIONS]
       qm shutdown <vmid> [OPTIONS]
       qm snapshot <vmid> <snapname> [OPTIONS]
       qm start <vmid> [OPTIONS]
       qm stop <vmid> [OPTIONS]
       qm suspend <vmid> [OPTIONS]
       qm template <vmid> [OPTIONS]
       qm unlink <vmid> --idlist <string> [OPTIONS]

       qm cleanup <vmid> <clean-shutdown> <guest-requested>
       qm importdisk <vmid> <source> <storage> [OPTIONS]
       qm importovf <vmid> <manifest> <storage> [OPTIONS]
       qm monitor <vmid>
       qm mtunnel
       qm nbdstop <vmid>
       qm rescan  [OPTIONS]
       qm showcmd <vmid> [OPTIONS]
       qm status <vmid> [OPTIONS]
       qm terminal <vmid> [OPTIONS]
       qm unlock <vmid>
       qm vncproxy <vmid>
       qm wait <vmid> [OPTIONS]

       qm help [<extra-args>] [OPTIONS]


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
everything is handled via "qm" or "pvesh". Use "man qm" for more information or search the web:

Code:
root@proxmox-1:~# qm
ERROR: no command specified
USAGE: qm <COMMAND> [ARGS] [OPTIONS]

       qm cloudinit dump <vmid> <type>

       qm guest cmd <vmid> <command>
       qm guest exec-status <vmid> <pid>
       qm guest passwd <vmid> <username> [OPTIONS]
       qm guest exec <vmid> [<extra-args>] [OPTIONS]

       qm clone <vmid> <newid> [OPTIONS]
       qm config <vmid> [OPTIONS]
       qm create <vmid> [OPTIONS]
       qm delsnapshot <vmid> <snapname> [OPTIONS]
       qm destroy <vmid> [OPTIONS]
       qm list  [OPTIONS]
       qm listsnapshot <vmid>
       qm migrate <vmid> <target> [OPTIONS]
       qm move_disk <vmid> <disk> <storage> [OPTIONS]
       qm pending <vmid>
       qm reboot <vmid> [OPTIONS]
       qm reset <vmid> [OPTIONS]
       qm resize <vmid> <disk> <size> [OPTIONS]
       qm resume <vmid> [OPTIONS]
       qm rollback <vmid> <snapname>
       qm sendkey <vmid> <key> [OPTIONS]
       qm set <vmid> [OPTIONS]
       qm shutdown <vmid> [OPTIONS]
       qm snapshot <vmid> <snapname> [OPTIONS]
       qm start <vmid> [OPTIONS]
       qm stop <vmid> [OPTIONS]
       qm suspend <vmid> [OPTIONS]
       qm template <vmid> [OPTIONS]
       qm unlink <vmid> --idlist <string> [OPTIONS]

       qm cleanup <vmid> <clean-shutdown> <guest-requested>
       qm importdisk <vmid> <source> <storage> [OPTIONS]
       qm importovf <vmid> <manifest> <storage> [OPTIONS]
       qm monitor <vmid>
       qm mtunnel
       qm nbdstop <vmid>
       qm rescan  [OPTIONS]
       qm showcmd <vmid> [OPTIONS]
       qm status <vmid> [OPTIONS]
       qm terminal <vmid> [OPTIONS]
       qm unlock <vmid>
       qm vncproxy <vmid>
       qm wait <vmid> [OPTIONS]

       qm help [<extra-args>] [OPTIONS]


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Hey! Thanks for the reply.

I have been toying around with qm - haven't looked into pvesh, but I will.

For network configuration, for example, I recognize that I should be using 'qm set <vmid> --ipconfig...,' and this does appear to correctly change the config at /etc/pve/qemu-server/<vmid>.conf, but an 'ip addr' run from a terminal inside of the VM shows no changes after a reboot of the VM.

I have been unable to find any examples for this command's use, but I have found many and many results pasting the contents of the man page for that command.

Any advice on what I might be missing?
 
Any advice on what I might be missing?
in the man page for "qm" press / (slash) and type --ipconfig. It will lead you to description of this option:
Code:
--ipconfig[n] [gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]
           cloud-init: Specify IP addresses and gateways for the corresponding interface.

           IP addresses use CIDR notation, gateways are optional but need an IP of the same type specified.

           The special string dhcp can be used for IP addresses to use DHCP, in which case no explicit gateway should be provided. For IPv6 the special string auto can be used to use stateless
           autoconfiguration. This requires cloud-init 19.4 or newer.

           If cloud-init is enabled and neither an IPv4 nor an IPv6 address is specified, it defaults to using dhcp on IPv4.


Notice the referral to "cloud-init", which is a whole another technology you can learn about:
https://cloudinit.readthedocs.io/en/latest/

Unless you are using cloud-init, you cant set IP address of the guest from the hypervisor. You should be doing it from the guest itself.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Unless you are using cloud-init, you cant set IP address of the guest from the hypervisor. You should be doing it from the guest itself.
That's the missing key - I didn't get that from the wording in the man page, but it makes sense now that you mention it.

Thank you for the assistance!
 
Quick update for anyone following this:

I set up cloud-init, and I am able to accomplish everything I was trying to do!

Thanks again to bbgeek17 for the assist!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!