mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-30 13:08:40 +00:00
vmstatus: define return propertries
We can use the same properties in vmlist and vmstatus. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
03f879fd85
commit
b1a70cab3d
@ -365,52 +365,7 @@ __PACKAGE__->register_method({
|
|||||||
type => 'array',
|
type => 'array',
|
||||||
items => {
|
items => {
|
||||||
type => "object",
|
type => "object",
|
||||||
properties => {
|
properties => $PVE::QemuServer::vmstatus_return_properties,
|
||||||
vmid => get_standard_option('pve-vmid'),
|
|
||||||
status => {
|
|
||||||
description => "Qemu process status.",
|
|
||||||
type => 'string',
|
|
||||||
enum => ['stopped', 'running'],
|
|
||||||
},
|
|
||||||
maxmem => {
|
|
||||||
description => "Maximum memory in bytes.",
|
|
||||||
type => 'integer',
|
|
||||||
optional => 1,
|
|
||||||
renderer => 'bytes',
|
|
||||||
},
|
|
||||||
maxdisk => {
|
|
||||||
description => "Root disk size in bytes.",
|
|
||||||
type => 'integer',
|
|
||||||
optional => 1,
|
|
||||||
renderer => 'bytes',
|
|
||||||
},
|
|
||||||
name => {
|
|
||||||
description => "VM name.",
|
|
||||||
type => 'string',
|
|
||||||
optional => 1,
|
|
||||||
},
|
|
||||||
qmpstatus => {
|
|
||||||
description => "Qemu QMP agent status.",
|
|
||||||
type => 'string',
|
|
||||||
optional => 1,
|
|
||||||
},
|
|
||||||
pid => {
|
|
||||||
description => "PID of running qemu process.",
|
|
||||||
type => 'integer',
|
|
||||||
optional => 1,
|
|
||||||
},
|
|
||||||
uptime => {
|
|
||||||
description => "Uptime.",
|
|
||||||
type => 'integer',
|
|
||||||
optional => 1,
|
|
||||||
renderer => 'duration',
|
|
||||||
},
|
|
||||||
cpus => {
|
|
||||||
description => "Maximum usable CPUs.",
|
|
||||||
type => 'number',
|
|
||||||
optional => 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
links => [ { rel => 'child', href => "{vmid}" } ],
|
links => [ { rel => 'child', href => "{vmid}" } ],
|
||||||
},
|
},
|
||||||
@ -427,7 +382,6 @@ __PACKAGE__->register_method({
|
|||||||
next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Audit' ], 1);
|
next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Audit' ], 1);
|
||||||
|
|
||||||
my $data = $vmstatus->{$vmid};
|
my $data = $vmstatus->{$vmid};
|
||||||
$data->{vmid} = int($vmid);
|
|
||||||
push @$res, $data;
|
push @$res, $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1908,7 +1862,26 @@ __PACKAGE__->register_method({
|
|||||||
vmid => get_standard_option('pve-vmid'),
|
vmid => get_standard_option('pve-vmid'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => { type => 'object' },
|
returns => {
|
||||||
|
type => 'object',
|
||||||
|
properties => {
|
||||||
|
%$PVE::QemuServer::vmstatus_return_properties,
|
||||||
|
ha => {
|
||||||
|
description => "HA manager service status.",
|
||||||
|
type => 'object',
|
||||||
|
},
|
||||||
|
spice => {
|
||||||
|
description => "Qemu VGA configuration supports spice.",
|
||||||
|
type => 'boolean',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
agent => {
|
||||||
|
description => "Qemu GuestAgent enabled in config.",
|
||||||
|
type => 'boolean',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
code => sub {
|
code => sub {
|
||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
|
@ -2764,6 +2764,53 @@ sub disksize {
|
|||||||
return $drive->{size};
|
return $drive->{size};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
our $vmstatus_return_properties = {
|
||||||
|
vmid => get_standard_option('pve-vmid'),
|
||||||
|
status => {
|
||||||
|
description => "Qemu process status.",
|
||||||
|
type => 'string',
|
||||||
|
enum => ['stopped', 'running'],
|
||||||
|
},
|
||||||
|
maxmem => {
|
||||||
|
description => "Maximum memory in bytes.",
|
||||||
|
type => 'integer',
|
||||||
|
optional => 1,
|
||||||
|
renderer => 'bytes',
|
||||||
|
},
|
||||||
|
maxdisk => {
|
||||||
|
description => "Root disk size in bytes.",
|
||||||
|
type => 'integer',
|
||||||
|
optional => 1,
|
||||||
|
renderer => 'bytes',
|
||||||
|
},
|
||||||
|
name => {
|
||||||
|
description => "VM name.",
|
||||||
|
type => 'string',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
qmpstatus => {
|
||||||
|
description => "Qemu QMP agent status.",
|
||||||
|
type => 'string',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
pid => {
|
||||||
|
description => "PID of running qemu process.",
|
||||||
|
type => 'integer',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
uptime => {
|
||||||
|
description => "Uptime.",
|
||||||
|
type => 'integer',
|
||||||
|
optional => 1,
|
||||||
|
renderer => 'duration',
|
||||||
|
},
|
||||||
|
cpus => {
|
||||||
|
description => "Maximum usable CPUs.",
|
||||||
|
type => 'number',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
my $last_proc_pid_stat;
|
my $last_proc_pid_stat;
|
||||||
|
|
||||||
# get VM status information
|
# get VM status information
|
||||||
@ -2789,7 +2836,7 @@ sub vmstatus {
|
|||||||
my $cfspath = PVE::QemuConfig->cfs_config_path($vmid);
|
my $cfspath = PVE::QemuConfig->cfs_config_path($vmid);
|
||||||
my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
|
my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
|
||||||
|
|
||||||
my $d = {};
|
my $d = { vmid => $vmid };
|
||||||
$d->{pid} = $list->{$vmid}->{pid};
|
$d->{pid} = $list->{$vmid}->{pid};
|
||||||
|
|
||||||
# fixme: better status?
|
# fixme: better status?
|
||||||
|
Loading…
Reference in New Issue
Block a user