I'm having trouble using the hookscript to run commands on the guest. The error I'm getting is QEMU guest agent is not running. However, I know this is wrong, since I can run the same commands after the VM is booted just fine. I thought it might be a problem with the QEMU agent needing extra time to startup, so I added a delay of 10 seconds and verified that that works OK, but that didn't solve the issue either.
And here's the output from the VM's startup log:
And just so no one tells me to double check that the guest agent is running (it is), terminal output from running a guest exec command at the command line:
Anyone have any ideas what I'm doing wrong?
Perl:
elsif ($phase eq 'post-start') {
# Second phase 'post-start' will be executed after the guest
# successfully started.
print scalar localtime();
print "\n";
sleep(10);
print scalar localtime();
print "\n";
system("qm guest exec $vmid -- mkdir ./test");
print "$vmid started successfully.\n";
}
And here's the output from the VM's startup log:
Code:
generating cloud-init ISO
GUEST HOOK: 802 pre-start
802 is starting, doing preparations.
iothread is only valid with virtio disk or virtio-scsi-single controller, ignoring
GUEST HOOK: 802 post-start
Tue Sep 27 13:56:31 2022
Tue Sep 27 13:56:41 2022
QEMU guest agent is not running
802 started successfully.
TASK OK
And just so no one tells me to double check that the guest agent is running (it is), terminal output from running a guest exec command at the command line:
Code:
qm guest exec 802 -- echo Worked!
{
"exitcode" : 0,
"exited" : 1,
"out-data" : "Worked!\n"
}
Anyone have any ideas what I'm doing wrong?