mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
block_resize: Define the new API
The new API is named as "virDomainBlockResize", intending to add support for qemu monitor command "block_resize" (both HMP and QMP). Similar with APIs like "virDomainSetMemoryFlags", the units for argument "size" is kilobytes.
This commit is contained in:
parent
dee901c1ff
commit
caef87d557
@ -1400,7 +1400,10 @@ int virDomainBlockPeek (virDomainPtr dom,
|
||||
size_t size,
|
||||
void *buffer,
|
||||
unsigned int flags);
|
||||
|
||||
int virDomainBlockResize (virDomainPtr dom,
|
||||
const char *disk,
|
||||
unsigned long long size,
|
||||
unsigned int flags);
|
||||
|
||||
/** virDomainBlockInfo:
|
||||
*
|
||||
|
@ -377,7 +377,12 @@ typedef int
|
||||
unsigned long long offset, size_t size,
|
||||
void *buffer,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainBlockResize)
|
||||
(virDomainPtr domain,
|
||||
const char *path,
|
||||
unsigned long long size,
|
||||
unsigned int flags);
|
||||
typedef int
|
||||
(*virDrvDomainMemoryPeek)
|
||||
(virDomainPtr domain,
|
||||
@ -846,6 +851,7 @@ struct _virDriver {
|
||||
virDrvDomainMigratePrepare domainMigratePrepare;
|
||||
virDrvDomainMigratePerform domainMigratePerform;
|
||||
virDrvDomainMigrateFinish domainMigrateFinish;
|
||||
virDrvDomainBlockResize domainBlockResize;
|
||||
virDrvDomainBlockStats domainBlockStats;
|
||||
virDrvDomainBlockStatsFlags domainBlockStatsFlags;
|
||||
virDrvDomainInterfaceStats domainInterfaceStats;
|
||||
|
@ -7090,6 +7090,74 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainBlockResize:
|
||||
* @dom: pointer to the domain object
|
||||
* @disk: path to the block image, or shorthand
|
||||
* @size: new size of the block image in kilobytes
|
||||
* @flags: unused, always pass 0
|
||||
*
|
||||
* Note that this call may fail if the underlying virtualization hypervisor
|
||||
* does not support it. And this call requires privileged access to the
|
||||
* hypervisor.
|
||||
*
|
||||
* The @disk parameter is either an unambiguous source name of the
|
||||
* block device (the <source file='...'/> sub-element, such as
|
||||
* "/path/to/image"), or (since 0.9.5) the device target shorthand
|
||||
* (the <target dev='...'/> sub-element, such as "xvda"). Valid names
|
||||
* can be found by calling virDomainGetXMLDesc() and inspecting
|
||||
* elements within //domain/devices/disk.
|
||||
*
|
||||
* Resize a block device of domain while the domain is running.
|
||||
*
|
||||
* Returns: 0 in case of success or -1 in case of failure.
|
||||
*/
|
||||
|
||||
int
|
||||
virDomainBlockResize (virDomainPtr dom,
|
||||
const char *disk,
|
||||
unsigned long long size,
|
||||
unsigned int flags)
|
||||
{
|
||||
virConnectPtr conn;
|
||||
|
||||
VIR_DOMAIN_DEBUG(dom, "disk=%s, size=%llu, flags=%x", disk, size, flags);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
|
||||
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||
virDispatchError(NULL);
|
||||
return -1;
|
||||
}
|
||||
conn = dom->conn;
|
||||
|
||||
if (dom->conn->flags & VIR_CONNECT_RO) {
|
||||
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!disk) {
|
||||
virLibDomainError(VIR_ERR_INVALID_ARG,
|
||||
_("disk is NULL"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (conn->driver->domainBlockResize) {
|
||||
int ret;
|
||||
ret =conn->driver->domainBlockResize(dom, disk, size, flags);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
|
||||
error:
|
||||
virDispatchError(dom->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainMemoryPeek:
|
||||
* @dom: pointer to the domain object
|
||||
|
@ -503,6 +503,7 @@ LIBVIRT_0.9.8 {
|
||||
virConnectIsAlive;
|
||||
virConnectSetKeepAlive;
|
||||
virNodeSuspendForDuration;
|
||||
virDomainBlockResize;
|
||||
} LIBVIRT_0.9.7;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
Loading…
x
Reference in New Issue
Block a user