commands-win32.c (b9a7cfee1280cc70ba0db2eb528ea3e5a072c80e) | commands-win32.c (64c003174039d0c63ea2bef48d600363ce80a58b) |
---|---|
1/* 2 * QEMU Guest Agent win32-specific command implementations 3 * 4 * Copyright IBM Corp. 2012 5 * 6 * Authors: 7 * Michael Roth <mdroth@linux.vnet.ibm.com> 8 * Gal Hammer <ghammer@redhat.com> 9 * 10 * This work is licensed under the terms of the GNU GPL, version 2 or later. 11 * See the COPYING file in the top-level directory. 12 */ 13 14#include <glib.h> 15#include <wtypes.h> 16#include <powrprof.h> 17#include "qga/guest-agent-core.h" | 1/* 2 * QEMU Guest Agent win32-specific command implementations 3 * 4 * Copyright IBM Corp. 2012 5 * 6 * Authors: 7 * Michael Roth <mdroth@linux.vnet.ibm.com> 8 * Gal Hammer <ghammer@redhat.com> 9 * 10 * This work is licensed under the terms of the GNU GPL, version 2 or later. 11 * See the COPYING file in the top-level directory. 12 */ 13 14#include <glib.h> 15#include <wtypes.h> 16#include <powrprof.h> 17#include "qga/guest-agent-core.h" |
18#include "qga/vss-win32.h" |
|
18#include "qga-qmp-commands.h" 19#include "qapi/qmp/qerror.h" 20 21#ifndef SHTDN_REASON_FLAG_PLANNED 22#define SHTDN_REASON_FLAG_PLANNED 0x80000000 23#endif 24 25/* multiple of 100 nanoseconds elapsed between windows baseline --- 125 unchanged lines hidden (view full) --- 151 error_set(err, QERR_UNSUPPORTED); 152} 153 154/* 155 * Return status of freeze/thaw 156 */ 157GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err) 158{ | 19#include "qga-qmp-commands.h" 20#include "qapi/qmp/qerror.h" 21 22#ifndef SHTDN_REASON_FLAG_PLANNED 23#define SHTDN_REASON_FLAG_PLANNED 0x80000000 24#endif 25 26/* multiple of 100 nanoseconds elapsed between windows baseline --- 125 unchanged lines hidden (view full) --- 152 error_set(err, QERR_UNSUPPORTED); 153} 154 155/* 156 * Return status of freeze/thaw 157 */ 158GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err) 159{ |
159 error_set(err, QERR_UNSUPPORTED); 160 return 0; | 160 if (!vss_initialized()) { 161 error_set(err, QERR_UNSUPPORTED); 162 return 0; 163 } 164 165 if (ga_is_frozen(ga_state)) { 166 return GUEST_FSFREEZE_STATUS_FROZEN; 167 } 168 169 return GUEST_FSFREEZE_STATUS_THAWED; |
161} 162 163/* | 170} 171 172/* |
164 * Walk list of mounted file systems in the guest, and freeze the ones which 165 * are real local file systems. | 173 * Freeze local file systems using Volume Shadow-copy Service. 174 * The frozen state is limited for up to 10 seconds by VSS. |
166 */ 167int64_t qmp_guest_fsfreeze_freeze(Error **err) 168{ | 175 */ 176int64_t qmp_guest_fsfreeze_freeze(Error **err) 177{ |
169 error_set(err, QERR_UNSUPPORTED); | 178 int i; 179 Error *local_err = NULL; 180 181 if (!vss_initialized()) { 182 error_set(err, QERR_UNSUPPORTED); 183 return 0; 184 } 185 186 slog("guest-fsfreeze called"); 187 188 /* cannot risk guest agent blocking itself on a write in this state */ 189 ga_set_frozen(ga_state); 190 191 qga_vss_fsfreeze(&i, err, true); 192 if (error_is_set(err)) { 193 goto error; 194 } 195 196 return i; 197 198error: 199 qmp_guest_fsfreeze_thaw(&local_err); 200 if (error_is_set(&local_err)) { 201 g_debug("cleanup thaw: %s", error_get_pretty(local_err)); 202 error_free(local_err); 203 } |
170 return 0; 171} 172 173/* | 204 return 0; 205} 206 207/* |
174 * Walk list of frozen file systems in the guest, and thaw them. | 208 * Thaw local file systems using Volume Shadow-copy Service. |
175 */ 176int64_t qmp_guest_fsfreeze_thaw(Error **err) 177{ | 209 */ 210int64_t qmp_guest_fsfreeze_thaw(Error **err) 211{ |
178 error_set(err, QERR_UNSUPPORTED); 179 return 0; | 212 int i; 213 214 if (!vss_initialized()) { 215 error_set(err, QERR_UNSUPPORTED); 216 return 0; 217 } 218 219 qga_vss_fsfreeze(&i, err, false); 220 221 ga_unset_frozen(ga_state); 222 return i; |
180} 181 | 223} 224 |
225static void guest_fsfreeze_cleanup(void) 226{ 227 Error *err = NULL; 228 229 if (!vss_initialized()) { 230 return; 231 } 232 233 if (ga_is_frozen(ga_state) == GUEST_FSFREEZE_STATUS_FROZEN) { 234 qmp_guest_fsfreeze_thaw(&err); 235 if (err) { 236 slog("failed to clean up frozen filesystems: %s", 237 error_get_pretty(err)); 238 error_free(err); 239 } 240 } 241 242 vss_deinit(true); 243} 244 |
|
182/* 183 * Walk list of mounted file systems in the guest, and discard unused 184 * areas. 185 */ 186void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) 187{ 188 error_set(err, QERR_UNSUPPORTED); 189} --- 159 unchanged lines hidden (view full) --- 349{ 350 error_set(errp, QERR_UNSUPPORTED); 351 return -1; 352} 353 354/* register init/cleanup routines for stateful command groups */ 355void ga_command_state_init(GAState *s, GACommandState *cs) 356{ | 245/* 246 * Walk list of mounted file systems in the guest, and discard unused 247 * areas. 248 */ 249void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) 250{ 251 error_set(err, QERR_UNSUPPORTED); 252} --- 159 unchanged lines hidden (view full) --- 412{ 413 error_set(errp, QERR_UNSUPPORTED); 414 return -1; 415} 416 417/* register init/cleanup routines for stateful command groups */ 418void ga_command_state_init(GAState *s, GACommandState *cs) 419{ |
420 if (vss_init(true)) { 421 ga_command_state_add(cs, NULL, guest_fsfreeze_cleanup); 422 } |
|
357} | 423} |