qga/win/vss: query VSS backup type
Query VSS backup type number (DWORD) from QEMU Guest Agent VSS Provider registry key registry value VssOption Translate the VSS backup type number (DWORD) into its VSS backup type (VSS_BACKUP_TYPE) Returns the queried VSS backup type if the program encounters unexpected behaviors or values return default VSS backup type VSS_BT_FULL instead Signed-off-by: Kfir Manor <kfir@daynix.com> Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
This commit is contained in:
parent
fe67fc0eb4
commit
410542d4a2
@ -23,6 +23,8 @@
|
|||||||
/* Call QueryStatus every 10 ms while waiting for frozen event */
|
/* Call QueryStatus every 10 ms while waiting for frozen event */
|
||||||
#define VSS_TIMEOUT_EVENT_MSEC 10
|
#define VSS_TIMEOUT_EVENT_MSEC 10
|
||||||
|
|
||||||
|
#define DEFAULT_VSS_BACKUP_TYPE VSS_BT_FULL
|
||||||
|
|
||||||
#define err_set(e, err, fmt, ...) \
|
#define err_set(e, err, fmt, ...) \
|
||||||
((e)->error_setg_win32_wrapper((e)->errp, __FILE__, __LINE__, __func__, \
|
((e)->error_setg_win32_wrapper((e)->errp, __FILE__, __LINE__, __func__, \
|
||||||
err, fmt, ## __VA_ARGS__))
|
err, fmt, ## __VA_ARGS__))
|
||||||
@ -234,6 +236,42 @@ out:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD get_reg_dword_value(HKEY baseKey, LPCSTR subKey, LPCSTR valueName,
|
||||||
|
DWORD defaultData)
|
||||||
|
{
|
||||||
|
DWORD regGetValueError;
|
||||||
|
DWORD dwordData;
|
||||||
|
DWORD dataSize = sizeof(DWORD);
|
||||||
|
|
||||||
|
regGetValueError = RegGetValue(baseKey, subKey, valueName, RRF_RT_DWORD,
|
||||||
|
NULL, &dwordData, &dataSize);
|
||||||
|
if (regGetValueError != ERROR_SUCCESS) {
|
||||||
|
return defaultData;
|
||||||
|
}
|
||||||
|
return dwordData;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_valid_vss_backup_type(VSS_BACKUP_TYPE vssBT)
|
||||||
|
{
|
||||||
|
return (vssBT > VSS_BT_UNDEFINED && vssBT < VSS_BT_OTHER);
|
||||||
|
}
|
||||||
|
|
||||||
|
VSS_BACKUP_TYPE get_vss_backup_type(
|
||||||
|
VSS_BACKUP_TYPE defaultVssBT = DEFAULT_VSS_BACKUP_TYPE)
|
||||||
|
{
|
||||||
|
VSS_BACKUP_TYPE vssBackupType;
|
||||||
|
|
||||||
|
vssBackupType = static_cast<VSS_BACKUP_TYPE>(
|
||||||
|
get_reg_dword_value(HKEY_LOCAL_MACHINE,
|
||||||
|
QGA_PROVIDER_REGISTRY_ADDRESS,
|
||||||
|
"VssOption",
|
||||||
|
defaultVssBT));
|
||||||
|
if (!is_valid_vss_backup_type(vssBackupType)) {
|
||||||
|
return defaultVssBT;
|
||||||
|
}
|
||||||
|
return vssBackupType;
|
||||||
|
}
|
||||||
|
|
||||||
void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
|
void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset)
|
||||||
{
|
{
|
||||||
COMPointer<IVssAsync> pAsync;
|
COMPointer<IVssAsync> pAsync;
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider"
|
#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider"
|
||||||
#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME)
|
#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME)
|
||||||
#define QGA_PROVIDER_VERSION L(QEMU_VERSION)
|
#define QGA_PROVIDER_VERSION L(QEMU_VERSION)
|
||||||
|
#define QGA_PROVIDER_REGISTRY_ADDRESS "SYSTEM\\CurrentControlSet"\
|
||||||
|
"\\Services"\
|
||||||
|
"\\" QGA_PROVIDER_NAME
|
||||||
|
|
||||||
#define EVENT_NAME_FROZEN "Global\\QGAVSSEvent-frozen"
|
#define EVENT_NAME_FROZEN "Global\\QGAVSSEvent-frozen"
|
||||||
#define EVENT_NAME_THAW "Global\\QGAVSSEvent-thaw"
|
#define EVENT_NAME_THAW "Global\\QGAVSSEvent-thaw"
|
||||||
|
Loading…
Reference in New Issue
Block a user