// SPDX-License-Identifier: GPL-2.0-only /* * An implementation of the host initiated guest snapshot for Hyper-V. * * Copyright (C) 2013, Microsoft, Inc. * Author : K. Y. Srinivasan <kys@microsoft.com>
*/
/* Don't use syslog() in the function since that can cause write to disk */ staticint vss_do_freeze(char *dir, unsignedint cmd)
{ int ret, fd = open(dir, O_RDONLY);
if (fd < 0) return 1;
ret = ioctl(fd, cmd, 0);
/* * If a partition is mounted more than once, only the first * FREEZE/THAW can succeed and the later ones will get * EBUSY/EINVAL respectively: there could be 2 cases: * 1) a user may mount the same partition to different directories * by mistake or on purpose; * 2) The subvolume of btrfs appears to have the same partition * mounted more than once.
*/ if (ret) { if ((cmd == FIFREEZE && errno == EBUSY) ||
(cmd == FITHAW && errno == EINVAL)) {
close(fd); return 0;
}
}
close(fd); return !!ret;
}
staticbool is_dev_loop(constchar *blkname)
{ char *buffer;
DIR *dir; struct dirent *entry; bool ret = false;
switch (op) { case VSS_OP_FREEZE: case VSS_OP_THAW:
error = vss_operate(op);
syslog(LOG_INFO, "VSS: op=%s: %s\n",
op == VSS_OP_FREEZE ? "FREEZE" : "THAW",
error ? "failed" : "succeeded");
if (error) {
error = HV_E_FAIL;
syslog(LOG_ERR, "op=%d failed!", op);
syslog(LOG_ERR, "report it with these files:");
syslog(LOG_ERR, "/etc/fstab and /proc/mounts");
} break; case VSS_OP_HOT_BACKUP:
syslog(LOG_INFO, "VSS: op=CHECK HOT BACKUP\n"); break; default:
syslog(LOG_ERR, "Illegal op:%d\n", op);
}
/* * The write() may return an error due to the faked VSS_OP_THAW * message upon hibernation. Ignore the error by resetting the * dev file, i.e. closing and re-opening it.
*/
vss_msg->error = error;
len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg)); if (len != sizeof(struct hv_vss_msg)) {
syslog(LOG_ERR, "write failed; error: %d %s", errno,
strerror(errno)); goto reopen_vss_fd;
}
}
close(vss_fd); exit(0);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.