packer-plugin-proxmox icon indicating copy to clipboard operation
packer-plugin-proxmox copied to clipboard

Packer can't parse e1000 device rx-packets from qemu-guest-agent

Open exotime opened this issue 3 years ago • 0 comments

Overview of the Issue

I'm trying to build a Windows 10 x64 VM from ISO in Proxmox with an e1000 network card. The VM builds and it installs the guest additions successfully, and reboots ready for remote connections. When Packer attempts to move into the provisioner stage (and it detects that the guest agent is now running), it fails to parse the statistics (specifically, rx-packets field). This appears to affect both WinRM and SSH provisioners (as its before it gets that far) and the impact is that a build script can not perform provisioner tasks.

I've verified that I can both SSH into, and use WinRM to connect to a PSRemote session, in both of these circumstances - so it shouldn't be a firewall or network issue between packer and the built VM, its just parsing the guest data breaks the flow before the connection attempt.

While this is probably caused by a bug in the qemu-guest-agent itself, I don't think a large integer here should cause the building of a VM to fail entirely.

Here's the user-facing log:

2022/11/23 19:38:26 packer-builder-proxmox plugin: [DEBUG] Error getting WinRM host: 500 QEMU guest agent is not running
2022/11/23 19:38:34 packer-builder-proxmox plugin: [DEBUG] Error getting WinRM host: error unmarshalling result json: cannot unmarshal number 18446744073709550573 into Go struct field .statistics of type int64

And a SSH example for completeness:

2022/11/23 20:22:35 packer-builder-proxmox plugin: [DEBUG] Error getting SSH address: error unmarshalling result json: cannot unmarshal number 18446744073709551612 into Go struct field .statistics of type int64

An example of the offending config - changing e1000 to virtio bypasses the problem.

      "network_adapters": [
        {
          "model": "e1000",
          "bridge": "vmbr0",
          "vlan_tag": "2"
        }
      ],

Once the VM is on the desktop and ready for WinRM, querying the guest-agent from the host shows an abnormal number of rx-packets:

$ sudo qm guest cmd 4020 network-get-interfaces
[sudo] password for exotime:
[
   {
      "hardware-address" : "ea:1f:7d:0e:ac:59",
      "ip-addresses" : [
         {
            "ip-address" : "192.168.2.175",
            "ip-address-type" : "ipv4",
            "prefix" : 24
         }
      ],
      "name" : "Ethernet Instance 0",
      "statistics" : {
         "rx-bytes" : 40048,
         "rx-dropped" : 0,
         "rx-errs" : 0,
         "rx-packets" : 18446744073709550900,
         "tx-bytes" : 30046,
         "tx-dropped" : 0,
         "tx-errs" : 0,
         "tx-packets" : 49
      }
   },
   {
      "ip-addresses" : [
         {
            "ip-address" : "::1",
            "ip-address-type" : "ipv6",
            "prefix" : 128
         },
         {
            "ip-address" : "127.0.0.1",
            "ip-address-type" : "ipv4",
            "prefix" : 8
         }
      ],
      "name" : "Loopback Pseudo-Interface 1",
      "statistics" : {
         "rx-bytes" : 0,
         "rx-dropped" : 0,
         "rx-errs" : 0,
         "rx-packets" : 0,
         "tx-bytes" : 0,
         "tx-dropped" : 0,
         "tx-errs" : 0,
         "tx-packets" : 0
      }
   }
]

But here's an example from the same build script with an virtio device:

[
   {
      "hardware-address" : "82:b2:d8:f0:80:cb",
      "ip-addresses" : [
         {
            "ip-address" : "192.168.2.179",
            "ip-address-type" : "ipv4",
            "prefix" : 24
         }
      ],
      "name" : "Ethernet Instance 0",
      "statistics" : {
         "rx-bytes" : 107278807,
         "rx-dropped" : 0,
         "rx-errs" : 0,
         "rx-packets" : 76758,
         "tx-bytes" : 4307312,
         "tx-dropped" : 0,
         "tx-errs" : 0,
         "tx-packets" : 52091
      }
   },
   {
      "ip-addresses" : [
         {
            "ip-address" : "::1",
            "ip-address-type" : "ipv6",
            "prefix" : 128
         },
         {
            "ip-address" : "127.0.0.1",
            "ip-address-type" : "ipv4",
            "prefix" : 8
         }
      ],
      "name" : "Loopback Pseudo-Interface 1",
      "statistics" : {
         "rx-bytes" : 0,
         "rx-dropped" : 0,
         "rx-errs" : 0,
         "rx-packets" : 0,
         "tx-bytes" : 0,
         "tx-dropped" : 0,
         "tx-errs" : 0,
         "tx-packets" : 0
      }
   }
]

At this point however, I can definitely establish a session (or SSH in, if I swap the config to try and use SSH instead).

Reproduction Steps

$ packer build ./simplest.json

Plugin and Packer version

$ packer version
Packer v1.8.4

VirtIO drivers 0.1.217 (April 14, 2022) (have also tried 0.1.171 (2019) and 0.1.185 (2020) in random sampling).

Simplified Packer Buildfile

simplest.json, reduced packer build file here. You'll need a Windows 10 x64 ISO and an autounattend.xml, though.

Operating system and Environment details

  1. Proxmox Virtual Environment 7.2-11
  2. Windows 10 x64 OEM
  3. A flat network between packer and the Proxmox API.

Log Fragments and crash.log files

Log file shared here.

exotime avatar Nov 28 '22 15:11 exotime