New APIs: pvchange-uuid, pvchange-uuid-all, vgchange-uuid, vgchange-uuid-all.

These APIs will allow sysprep to change the UUIDs of all PVs and VGs
in the system.

LVs don't have UUIDs AFAICT, or at least there seems to be no way to
change them if they do have them.
This commit is contained in:
Richard W.M. Jones
2012-07-25 10:29:58 +01:00
parent 2b59b5f1d2
commit e64bf3fb29
3 changed files with 147 additions and 1 deletions

View File

@@ -960,3 +960,87 @@ do_vgmeta (const char *vg, size_t *size_r)
return buf; /* caller will free */
}
int
do_pvchange_uuid (const char *device)
{
char *err;
int r;
r = command (NULL, &err,
"lvm", "pvchange", "-u", device, NULL);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
free (err);
return -1;
}
free (err);
udev_settle ();
return 0;
}
int
do_pvchange_uuid_all (void)
{
char *err;
int r;
r = command (NULL, &err,
"lvm", "pvchange", "-u", "-a", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
return -1;
}
free (err);
udev_settle ();
return 0;
}
int
do_vgchange_uuid (const char *vg)
{
char *err;
int r;
r = command (NULL, &err,
"lvm", "vgchange", "-u", vg, NULL);
if (r == -1) {
reply_with_error ("%s: %s", vg, err);
free (err);
return -1;
}
free (err);
udev_settle ();
return 0;
}
int
do_vgchange_uuid_all (void)
{
char *err;
int r;
r = command (NULL, &err,
"lvm", "vgchange", "-u", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
return -1;
}
free (err);
udev_settle ();
return 0;
}

View File

@@ -8975,6 +8975,68 @@ The returned struct contains geometry information. Missing
fields are returned as C<-1> (for numeric fields) or empty
string." };
{ defaults with
name = "pvchange_uuid";
style = RErr, [Device "device"], [];
proc_nr = Some 338;
optional = Some "lvm2";
tests = [
InitEmpty, IfAvailable "lvm2", TestRun (
[["part_disk"; "/dev/sda"; "mbr"];
["pvcreate"; "/dev/sda1"];
["pvchange_uuid"; "/dev/sda1"]])
];
shortdesc = "generate a new random UUID for a physical volume";
longdesc = "\
Generate a new random UUID for the physical volume C<device>." };
{ defaults with
name = "pvchange_uuid_all";
style = RErr, [], [];
proc_nr = Some 339;
optional = Some "lvm2";
tests = [
InitEmpty, IfAvailable "lvm2", TestRun (
[["part_disk"; "/dev/sda"; "mbr"];
["pvcreate"; "/dev/sda1"];
["pvchange_uuid_all"]])
];
shortdesc = "generate new random UUIDs for all physical volumes";
longdesc = "\
Generate new random UUIDs for all physical volumes." };
{ defaults with
name = "vgchange_uuid";
style = RErr, [String "vg"], [];
proc_nr = Some 340;
optional = Some "lvm2";
tests = [
InitEmpty, IfAvailable "lvm2", TestRun (
[["part_disk"; "/dev/sda"; "mbr"];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["vgchange_uuid"; "/dev/VG"]])
];
shortdesc = "generate a new random UUID for a volume group";
longdesc = "\
Generate a new random UUID for the volume group C<vg>." };
{ defaults with
name = "vgchange_uuid_all";
style = RErr, [], [];
proc_nr = Some 341;
optional = Some "lvm2";
tests = [
InitEmpty, IfAvailable "lvm2", TestRun (
[["part_disk"; "/dev/sda"; "mbr"];
["pvcreate"; "/dev/sda1"];
["vgcreate"; "VG"; "/dev/sda1"];
["vgchange_uuid_all"]])
];
shortdesc = "generate new random UUIDs for all volume groups";
longdesc = "\
Generate new random UUIDs for all volume groups." };
]
(* Non-API meta-commands available only in guestfish.

View File

@@ -1 +1 @@
337
341