qga/win/vss: add VSS backup type options
cover qga/win/vss: add VSS backup type options
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/775
The problem, VSS backup type VSS-FULL (the only available VSS backup type currently) can break other backups that use VSS-FULL(for example, Bareos-Fullbackup).
Fix, add other backup types.
Implementation, put the desired backup type number inside Regkey value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\QEMU Guest Agent VSS Provider\VssOption, so that the program can query the desired backup type.
VSS backup types:
number type 1 VSS_BT_FULL 2 VSS_BT_INCREMENTAL 3 VSS_BT_DIFFERENTIAL 4 VSS_BT_LOG 5 VSS_BT_COPY
for more information about the different backup types https://learn.microsoft.com/en-us/windows/win32/vss/vss-backup-state
Additionally, the program would work as before with VSS-FULL in cases where VssOption doesn't exist, or VssOption value isn't a known backup type.
Kfir Manor (3):
add VssOption to installer
query VSS backup type
requester_freeze changes
qga/installer/qemu-ga.wxs | 4 ++++ qga/vss-win32/requester.cpp | 41 ++++++++++++++++++++++++++++++++++++- qga/vss-win32/vss-handles.h | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-)
Signature · 1 line
2.38.1
PATCH 1/3 qga/win/installer: add VssOption to installer
Adds registry value VssOption with value 1 to QEMU Guest Agent VSS Provider service registry key
--- qga/installer/qemu-ga.wxs | 4 ++++ 1 file changed, 4 insertions(+)
qga/installer/qemu-ga.wxs +4 -0
@@ -121,6 +121,10 @@ <RegistryValue Type="integer" Name="TypesSupported" Value="7" /> <RegistryValue Type="string" Name="EventMessageFile" Value="[qemu_ga_directory]qemu-ga.exe" /> </RegistryKey> + <RegistryKey Root="HKLM" + Key="System\CurrentControlSet\Services\QEMU Guest Agent VSS Provider"> + <RegistryValue Type="integer" Name="VssOption" Value="1" /> + </RegistryKey> </Component> </Directory> </Directory>
Signature · 1 line
2.38.1
Re: [PATCH 1/3] qga/win/installer: add VssOption to installer
Quoted 30 lines · Kfir Manor
Adds registry value VssOption with value 1 to QEMU Guest Agent VSS Provider service registry key
Signed-off-by Kfir Manor <[email protected]>--- qga/installer/qemu-ga.wxs | 4 ++++ 1 file changed, 4 insertions(+)qga/installer/qemu-ga.wxs +0
-0@@ -121,6 +121,10 @@ <RegistryValue Type="integer" Name="TypesSupported"Value="7" />
<RegistryValue Type="string" Name="EventMessageFile"
Value="[qemu_ga_directory]qemu-ga.exe" />
</RegistryKey>qga/installer/qemu-ga.wxs +2
-0+ <RegistryKey Root="HKLM" + Key="System\CurrentControlSet\Services\QEMUGuest Agent VSS Provider">
qga/installer/qemu-ga.wxs +2
-1+ <RegistryValue Type="integer" Name="VssOption" Value="1" /> + </RegistryKey> </Component> </Directory> </Directory> --2.38.1
PATCH 2/3 qga/win/vss: query VSS backup type
In reply to Kfir ManorQuery 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
--- qga/vss-win32/requester.cpp | 38 +++++++++++++++++++++++++++++++++++++ qga/vss-win32/vss-handles.h | 3 +++ 2 files changed, 41 insertions(+)
qga/vss-win32/requester.cpp +38 -0
@@ -23,6 +23,8 @@ /* Call QueryStatus every 10 ms while waiting for frozen event */ #define VSS_TIMEOUT_EVENT_MSEC 10 +#define DEFAULT_VSS_BACKUP_TYPE VSS_BT_FULL + #define err_set(e, err, fmt, ...) \ ((e)->error_setg_win32_wrapper((e)->errp, __FILE__, __LINE__, __func__, \ 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) { COMPointer<IVssAsync> pAsync;
qga/vss-win32/vss-handles.h +3 -0
@@ -6,6 +6,9 @@#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider"#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME)#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_THAW "Global\\QGAVSSEvent-thaw"
Signature · 1 line
2.38.1
Re: [PATCH 2/3] qga/win/vss: query VSS backup type
Quoted 93 lines · Kfir Manor
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_FULLinsteadSigned-off-by Kfir Manor <[email protected]>--- qga/vss-win32/requester.cpp | 38 +++++++++++++++++++++++++++++++++++++ qga/vss-win32/vss-handles.h | 3 +++ 2 files changed, 41 insertions(+)qga/vss-win32/requester.cpp +2
-0@@ -23,6 +23,8 @@ /* Call QueryStatus every 10 ms while waiting for frozen event */ #define VSS_TIMEOUT_EVENT_MSEC 10 +#define DEFAULT_VSS_BACKUP_TYPE VSS_BT_FULL + #define err_set(e, err, fmt, ...) \ ((e)->error_setg_win32_wrapper((e)->errp, __FILE__, __LINE__,__func__, \ err, fmt, ## __VA_ARGS__))qga/vss-win32/requester.cpp +36
-0@@ -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){ COMPointer<IVssAsync> pAsync;qga/vss-win32/vss-handles.h +3
-1@@ -6,6 +6,9 @@#define QGA_PROVIDER_NAME "QEMU Guest Agent VSS Provider"#define QGA_PROVIDER_LNAME L(QGA_PROVIDER_NAME)#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_THAW "Global\\QGAVSSEvent-thaw" --2.38.1
PATCH 3/3 qga/win/vss: requester_freeze changes
In reply to Kfir ManorChange requester_freeze so that the VSS backup type queried from the registry
--- qga/vss-win32/requester.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
qga/vss-win32/requester.cpp +2 -1
@@ -285,6 +285,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset) DWORD wait_status; int num_fixed_drives = 0, i; int num_mount_points = 0; + VSS_BACKUP_TYPE vss_bt = get_vss_backup_type(); if (vss_ctx.pVssbc) { /* already frozen */ *num_vols = 0;
@@ -332,7 +333,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset) goto out; } - hr = vss_ctx.pVssbc->SetBackupState(true, true, VSS_BT_FULL, false); + hr = vss_ctx.pVssbc->SetBackupState(true, true, vss_bt, false); if (FAILED(hr)) { err_set(errset, hr, "failed to set backup state"); goto out;
Signature · 1 line
2.38.1
Re: [PATCH 3/3] qga/win/vss: requester_freeze changes
Quoted 35 lines · Kfir Manor
Change
requester_freezeso that the VSS backup type queried from the registrySigned-off-by Kfir Manor <[email protected]>--- qga/vss-win32/requester.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)qga/vss-win32/requester.cpp +1
-0@@ -285,6 +285,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset) DWORD wait_status; int num_fixed_drives = 0, i; int num_mount_points = 0; + VSS_BACKUP_TYPE vss_bt = get_vss_backup_type(); if (vss_ctx.pVssbc) { /* already frozen */*num_vols = 0;qga/vss-win32/requester.cpp +1
-1@@ -332,7 +333,7 @@ void requester_freeze(int *num_vols, void *mountpoints, ErrorSet *errset) goto out; } - hr = vss_ctx.pVssbc->SetBackupState(true, true, VSS_BT_FULL, false); + hr = vss_ctx.pVssbc->SetBackupState(true, true, vss_bt, false); if (FAILED(hr)) { err_set(errset, hr, "failed to set backup state");goto out;--
2.38.1
Hi Marc-André,
Can you please review this patch set?
Best Regards,
Konstantin Kostiuk.
Quoted 40 lines · Kfir Manor
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/775
The problem, VSS backup type VSS-FULL (the only available VSS backup type currently) can break other backups that use VSS-FULL(for example, Bareos-Fullbackup).
Fix, add other backup types.
Implementation, put the desired backup type number inside Regkey value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\QEMU Guest Agent VSS Provider\VssOption, so that the program can query the desired backup type.
VSS backup types:
number type 1 VSS_BT_FULL 2 VSS_BT_INCREMENTAL 3 VSS_BT_DIFFERENTIAL 4 VSS_BT_LOG 5 VSS_BT_COPYfor more information about the different backup types
https://learn.microsoft.com/en-us/windows/win32/vss/vss-backup-stateAdditionally, the program would work as before with VSS-FULL in cases where VssOption doesn't exist, or VssOption value isn't a known backup type.
Kfir Manor (3):
add VssOption to installer
query VSS backup type
requester_freezechangesqga/installer/qemu-ga.wxs | 4 ++++ qga/vss-win32/requester.cpp | 41 ++++++++++++++++++++++++++++++++++++- qga/vss-win32/vss-handles.h | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-)--
2.38.1
Hi
Quoted 37 lines · Konstantin Kostiuk
Hi Marc-André,
Can you please review this patch set?
Best Regards,
Konstantin Kostiuk.Quoted 26 lines · Kfir Manor
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/775
The problem, VSS backup type VSS-FULL (the only available VSS backup type currently) can break other backups that use VSS-FULL(for example, Bareos-Fullbackup).
Fix, add other backup types.
Implementation, put the desired backup type number inside Regkey value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\QEMU Guest Agent VSS Provider\VssOption, so that the program can query the desired backup type.
VSS backup types:
number type 1 VSS_BT_FULL 2 VSS_BT_INCREMENTAL 3 VSS_BT_DIFFERENTIAL 4 VSS_BT_LOG 5 VSS_BT_COPYfor more information about the different backup types
https://learn.microsoft.com/en-us/windows/win32/vss/vss-backup-stateAdditionally, the program would work as before with VSS-FULL in cases where VssOption doesn't exist, or VssOption value isn't a known backup type.
The patch series looks ok (just minor stylistic changes could be made), but I do not fully understand the way qga-vss.dll works in details for freeze/thaw.
My understanding is that FIFREEZE do not exist on win32, so we call VSS to tell (some) apps to flush/freeze pretending a backup is going on, then we get notified on completion by our own provider (CommitSnapshots) and wait there for thaw (1 min while VM is suspended?).
But I don't understand how this interacts with other providers (real backup solutions), and why they are involved/conflict as described in
https://gitlab.com/qemu-project/qemu/-/issues/775.
Quoted 15 lines
Quoted 15 lines
Kfir Manor (3):
add VssOption to installer
query VSS backup type
requester_freezechangesqga/installer/qemu-ga.wxs | 4 ++++ qga/vss-win32/requester.cpp | 41 ++++++++++++++++++++++++++++++++++++- qga/vss-win32/vss-handles.h | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-)--
2.38.1
Quoted 46 lines · Marc-André Lureau
Hi
Quoted 37 lines · Konstantin Kostiuk
Hi Marc-André,
Can you please review this patch set?
Best Regards,
Konstantin Kostiuk.Quoted 26 lines · Kfir Manor
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/775
The problem, VSS backup type VSS-FULL (the only available VSS backup type currently) can break other backups that use VSS-FULL(for example, Bareos-Fullbackup).
Fix, add other backup types.
Implementation, put the desired backup type number inside Regkey value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\QEMU Guest Agent VSS Provider\VssOption, so that the program can query the desired backup type.
VSS backup types:
number type 1 VSS_BT_FULL 2 VSS_BT_INCREMENTAL 3 VSS_BT_DIFFERENTIAL 4 VSS_BT_LOG 5 VSS_BT_COPYfor more information about the different backup types
https://learn.microsoft.com/en-us/windows/win32/vss/vss-backup-stateAdditionally, the program would work as before with VSS-FULL in cases where VssOption doesn't exist, or VssOption value isn't a known backup type.
The patch series looks ok (just minor stylistic changes could be made), but I do not fully understand the way qga-vss.dll works in details for freeze/thaw.
Quoted 9 lines
My understanding is that FIFREEZE do not exist on win32, so we call VSS to tell (some) apps to flush/freeze pretending a backup is going on, then we get notified on completion by our own provider (CommitSnapshots) and wait there for thaw (1 min while VM is suspended?).
But I don't understand how this interacts with other providers (real backup solutions), and why they are involved/conflict as described in
https://gitlab.com/qemu-project/qemu/-/issues/775.
This is a very good question. To understand the reason for the conflict we should dig deeper into VSS.
For some reason, MS provides different VSS backup types. Currently, we don't use other types but we got
a request from the community. I think this is ok, to add more freedom of configuration if someone wants it.
Anyway, the default behavior is not changed.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Kfir Manor (3):
add VssOption to installer
query VSS backup type
requester_freezechangesqga/installer/qemu-ga.wxs | 4 ++++ qga/vss-win32/requester.cpp | 41 ++++++++++++++++++++++++++++++++++++- qga/vss-win32/vss-handles.h | 3 +++ 3 files changed, 47 insertions(+), 1 deletion(-)--
2.38.1