[pve-devel] applied: [PATCH qemu-server v2 1/2] Make agent a property string, add fstrim_cloned_disks
Stoiko Ivanov
s.ivanov at proxmox.com
Thu Aug 2 15:48:23 CEST 2018
On Thu, 2 Aug 2018 12:18:44 +0200
Thomas Lamprecht <t.lamprecht at proxmox.com> wrote:
> Am 08/01/2018 um 08:29 PM schrieb Stoiko Ivanov:
> > Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
>
> applied, but it would be additionally great if the fstrim_cloned_disk
> setting would be a 'hot-pluggable' one, i.e., if it could be made on a
> running VM without needing to stop/start it. It's only a abstract
> setting not affecting the VM hardware layout and I could
> enable/disable this just fine if the QGA is already enabled.
Agreed - I'll take a look and provide a follow-up patch.
>
> > ---
> > PVE/API2/Qemu.pm | 3 +--
> > PVE/QemuConfig.pm | 2 +-
> > PVE/QemuServer.pm | 38 +++++++++++++++++++++++++++++++++-----
> > 3 files changed, 35 insertions(+), 8 deletions(-)
> >
> > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> > index b3f8134..464ba7f 100644
> > --- a/PVE/API2/Qemu.pm
> > +++ b/PVE/API2/Qemu.pm
> > @@ -1894,8 +1894,7 @@ __PACKAGE__->register_method({
> > $status->{ha} =
> > PVE::HA::Config::get_service_status("vm:$param->{vmid}");
> > $status->{spice} = 1 if
> > PVE::QemuServer::vga_conf_has_spice($conf->{vga}); -
> > - $status->{agent} = 1 if $conf->{agent};
> > + $status->{agent} = 1 if
> > (PVE::QemuServer::parse_guest_agent($conf)->{enabled});
> > return $status;
> > }});
> > diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
> > index 9a29b53..b24773c 100644
> > --- a/PVE/QemuConfig.pm
> > +++ b/PVE/QemuConfig.pm
> > @@ -161,7 +161,7 @@ sub __snapshot_check_freeze_needed {
> >
> > my $running = $class->__snapshot_check_running($vmid);
> > if (!$save_vmstate) {
> > - return ($running, $running && $config->{agent} &&
> > PVE::QemuServer::qga_check_running($vmid));
> > + return ($running, $running &&
> > PVE::QemuServer::parse_guest_agent($config)->{enabled} &&
> > PVE::QemuServer::qga_check_running($vmid)); } else { return
> > ($running, 0); }
> > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> > index ba09fc3..1c0fba2 100644
> > --- a/PVE/QemuServer.pm
> > +++ b/PVE/QemuServer.pm
> > @@ -200,6 +200,21 @@ my $watchdog_fmt = {
> > };
> > PVE::JSONSchema::register_format('pve-qm-watchdog', $watchdog_fmt);
> >
> > +my $agent_fmt = {
> > + enabled => {
> > + description => "Enable/disable Qemu GuestAgent.",
> > + type => 'boolean',
> > + default => 0,
> > + default_key => 1,
> > + },
> > + fstrim_cloned_disks => {
> > + description => "Run fstrim after cloning/moving a disk.",
> > + type => 'boolean',
> > + optional => 1,
> > + default => 0
> > + },
> > +};
> > +
> > my $confdesc = {
> > onboot => {
> > optional => 1,
> > @@ -380,9 +395,9 @@ EODESC
> > },
> > agent => {
> > optional => 1,
> > - type => 'boolean',
> > - description => "Enable/disable Qemu GuestAgent.",
> > - default => 0,
> > + description => "Enable/disable Qemu GuestAgent and its
> > properties.",
> > + type => 'string',
> > + format => $agent_fmt,
> > },
> > kvm => {
> > optional => 1,
> > @@ -2211,6 +2226,19 @@ sub parse_watchdog {
> > return $res;
> > }
> >
> > +sub parse_guest_agent {
> > + my ($value) = @_;
> > +
> > + return {} if !defined($value->{agent});
> > +
> > + my $res = eval
> > { PVE::JSONSchema::parse_property_string($agent_fmt,
> > $value->{agent}) };
> > + warn $@ if $@;
> > +
> > + # if the agent is disabled ignore the other potentially set
> > properties
> > + return {} if !$res->{enabled};
> > + return $res;
> > +}
> > +
> > PVE::JSONSchema::register_format('pve-qm-usb-device',
> > \&verify_usb_device); sub verify_usb_device {
> > my ($value, $noerr) = @_;
> > @@ -3442,7 +3470,7 @@ sub config_to_command {
> > #push @$cmd, '-soundhw', 'es1370';
> > #push @$cmd, '-soundhw', $soundhw if $soundhw;
> >
> > - if($conf->{agent}) {
> > + if (parse_guest_agent($conf)->{enabled}) {
> > my $qgasocket = qmp_socket($vmid, 1);
> > my $pciaddr = print_pci_addr("qga0", $bridges);
> > push @$devices, '-chardev',
> > "socket,path=$qgasocket,server,nowait,id=qga0"; @@ -5152,7 +5180,7
> > @@ sub vm_stop {
> > eval {
> > if ($shutdown) {
> > - if (defined($conf) && $conf->{agent}) {
> > + if (defined($conf) &&
> > parse_guest_agent($conf)->{enabled}) { vm_qmp_command($vmid,
> > { execute => "guest-shutdown" }, $nocheck); } else {
> > vm_qmp_command($vmid, { execute =>
> > "system_powerdown" }, $nocheck);
>
More information about the pve-devel
mailing list