[PATCH] Add missing oraclelinux cases.
by Jamie Iles
oraclelinux is the same as redhat/centos/scientificlinux, so add it
where it is missing. This fixes amongst other things, running sysprep
on an Oracle Linux image where it would previously fail operations like
setting the hostname, saying that it was not supported on that distro.
---
customize/firstboot.ml | 2 +-
customize/hostname.ml | 4 ++--
customize/password.ml | 4 ++--
customize/random_seed.ml | 2 +-
p2v/virt-p2v-make-disk.in | 2 +-
sysprep/sysprep_operation_net_hostname.ml | 2 +-
sysprep/sysprep_operation_net_hwaddr.ml | 2 +-
sysprep/sysprep_operation_pacct_log.ml | 2 +-
v2v/linux.ml | 2 +-
9 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/customize/firstboot.ml b/customize/firstboot.ml
index ddcb5627143d..b07bda00165a 100644
--- a/customize/firstboot.ml
+++ b/customize/firstboot.ml
@@ -154,7 +154,7 @@ WantedBy=%s
and install_sysvinit_service g root distro major =
match distro with
- | "fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based" ->
+ | "fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based" ->
install_sysvinit_redhat g
| "opensuse"|"sles"|"suse-based" ->
install_sysvinit_suse g
diff --git a/customize/hostname.ml b/customize/hostname.ml
index b49db8714df1..ee2c91e6a55d 100644
--- a/customize/hostname.ml
+++ b/customize/hostname.ml
@@ -36,7 +36,7 @@ let rec set_hostname (g : Guestfs.guestfs) root hostname =
update_etc_machine_info g hostname;
true
- | "linux", ("rhel"|"centos"|"scientificlinux"|"redhat-based"), v
+ | "linux", ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v
when v >= 7 ->
update_etc_hostname g hostname;
update_etc_machine_info g hostname;
@@ -48,7 +48,7 @@ let rec set_hostname (g : Guestfs.guestfs) root hostname =
replace_host_in_etc_hosts g old_hostname hostname;
true
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based"), _ ->
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), _ ->
replace_line_in_file g "/etc/sysconfig/network" "HOSTNAME" hostname;
true
diff --git a/customize/password.ml b/customize/password.ml
index d26b9486590e..dc69b8eb718d 100644
--- a/customize/password.ml
+++ b/customize/password.ml
@@ -144,9 +144,9 @@ and default_crypto g root =
let distro = g#inspect_get_distro root in
let major = g#inspect_get_major_version root in
match distro, major with
- | ("rhel"|"centos"|"scientificlinux"|"redhat-based"), v when v >= 6 ->
+ | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v when v >= 6 ->
`SHA512
- | ("rhel"|"centos"|"scientificlinux"|"redhat-based"), _ ->
+ | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), _ ->
`MD5 (* RHEL 5 does not appear to support SHA512, according to crypt(3) *)
| "fedora", v when v >= 9 -> `SHA512
diff --git a/customize/random_seed.ml b/customize/random_seed.ml
index fd0d7ed22009..3ddf25471ffa 100644
--- a/customize/random_seed.ml
+++ b/customize/random_seed.ml
@@ -47,7 +47,7 @@ let rec set_random_seed (g : Guestfs.guestfs) root =
let distro = g#inspect_get_distro root in
let file =
match typ, distro with
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
Some "/var/lib/random-seed"
| "linux", ("debian"|"ubuntu") ->
Some "/var/lib/urandom/random-seed"
diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in
index 2f1bf2b052f3..987dc31d9e45 100644
--- a/p2v/virt-p2v-make-disk.in
+++ b/p2v/virt-p2v-make-disk.in
@@ -169,7 +169,7 @@ xzcat "$virt_p2v_xz_binary" > "$virt_p2v_binary"
# Variations depending on the target distro. The main difference
# is in the list of distro packages we add to the base appliance.
case "$osversion" in
- centos-*|fedora-*|rhel-*|scientificlinux-*)
+ centos-*|fedora-*|rhel-*|scientificlinux-*|oraclelinux-*)
depsfile="$datadir/dependencies.redhat"
cat > $tmpdir/p2v.conf <<'EOF'
add_drivers+=" usb-storage "
diff --git a/sysprep/sysprep_operation_net_hostname.ml b/sysprep/sysprep_operation_net_hostname.ml
index b455e5c93d66..fe3f47412d0f 100644
--- a/sysprep/sysprep_operation_net_hostname.ml
+++ b/sysprep/sysprep_operation_net_hostname.ml
@@ -28,7 +28,7 @@ let net_hostname_perform (g : Guestfs.guestfs) root side_effects =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
Array.iter (
fun filename ->
diff --git a/sysprep/sysprep_operation_net_hwaddr.ml b/sysprep/sysprep_operation_net_hwaddr.ml
index 21cae1be490e..344eadc5bb99 100644
--- a/sysprep/sysprep_operation_net_hwaddr.ml
+++ b/sysprep/sysprep_operation_net_hwaddr.ml
@@ -28,7 +28,7 @@ let net_hwaddr_perform (g : Guestfs.guestfs) root side_effects =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
Array.iter (
fun filename ->
diff --git a/sysprep/sysprep_operation_pacct_log.ml b/sysprep/sysprep_operation_pacct_log.ml
index 1f9f0be27d6b..047cb39f3ef5 100644
--- a/sysprep/sysprep_operation_pacct_log.ml
+++ b/sysprep/sysprep_operation_pacct_log.ml
@@ -25,7 +25,7 @@ let pacct_log_perform (g : Guestfs.guestfs) root side_effects =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
let files = g#glob_expand "/var/account/pacct*" in
Array.iter (
fun file ->
diff --git a/v2v/linux.ml b/v2v/linux.ml
index 7996545114b3..a1c2c25a5d0b 100644
--- a/v2v/linux.ml
+++ b/v2v/linux.ml
@@ -87,7 +87,7 @@ let file_list_of_package (g : Guestfs.guestfs) inspect app =
match inspect with
| { i_type = "linux";
i_distro = "rhel" | "centos" | "scientificlinux" |
- "redhat-based";
+ "oraclelinux" | "redhat-based";
i_major_version = v } when v < 5 -> true
| _ -> false in
if is_rhel_lt_5 then
--
2.13.3
7 years, 4 months
[PATCH 1/1] New partition API: part_resize
by Nikos Skalkotos
This can be used to enlarge or shrink an existing partition.
---
daemon/parted.c | 31 +++++++++++++++++++++++++++++++
generator/actions_core.ml | 22 ++++++++++++++++++++++
generator/proc_nr.ml | 1 +
lib/MAX_PROC_NR | 2 +-
4 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/daemon/parted.c b/daemon/parted.c
index 72e1b8420..f1205cadf 100644
--- a/daemon/parted.c
+++ b/daemon/parted.c
@@ -178,6 +178,37 @@ do_part_del (const char *device, int partnum)
}
int
+do_part_resize (const char *device, int partnum, int64_t endsect)
+{
+ int r;
+ CLEANUP_FREE char *err = NULL;
+ char endstr[32];
+ char partnum_str[16];
+
+ if (partnum <= 0) {
+ reply_with_error ("partition number must be >= 1");
+ return -1;
+ }
+
+ snprintf (partnum_str, sizeof partnum_str, "%d", partnum);
+ snprintf (endstr, sizeof endstr, "%" PRIi64 "s", endsect);
+
+ udev_settle ();
+
+ r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
+ "parted", "-s", "--", device, "resizepart", partnum_str,
+ endstr, NULL);
+ if (r == -1) {
+ reply_with_error ("parted: %s: %s:", device, err);
+ return -1;
+ }
+
+ udev_settle();
+
+ return 0;
+}
+
+int
do_part_disk (const char *device, const char *parttype)
{
int r;
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index ea0735676..939aec7ee 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -9646,4 +9646,26 @@ be mountable but require special options. Filesystems may
not all belong to a single logical operating system
(use C<guestfs_inspect_os> to look for OSes)." };
+ { defaults with
+ name = "part_resize"; added = (1, 37, 20);
+ style = RErr, [String (Device, "device"); Int "partnum"; Int64 "endsect"], [];
+ tests = [
+ InitEmpty, Always, TestRun (
+ [["part_init"; "/dev/sda"; "mbr"];
+ ["part_add"; "/dev/sda"; "primary"; "1"; "-1025"];
+ ["part_resize"; "/dev/sda"; "1"; "-1"]]), []
+ ];
+ shortdesc = "resize a partition";
+ longdesc = "\
+This command resizes the partition numbered C<partnum> on C<device>
+by moving the end position.
+
+Note that this does not modify any filesystem present in the partition.
+If you wish to do this, you will need to use filesystem resizing
+commands like C<guestfs_resize2fs>.
+
+When growing a partition you will want to grow the filesystem
+afterwards, but when shrinking, you need to shrink the filesystem
+before the partition." };
+
]
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
index dec02f5fa..7895063b6 100644
--- a/generator/proc_nr.ml
+++ b/generator/proc_nr.ml
@@ -484,6 +484,7 @@ let proc_nr = [
474, "internal_yara_scan";
475, "file_architecture";
476, "list_filesystems";
+477, "part_resize";
]
(* End of list. If adding a new entry, add it at the end of the list
diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
index b86395733..bf2c10d23 100644
--- a/lib/MAX_PROC_NR
+++ b/lib/MAX_PROC_NR
@@ -1 +1 @@
-476
+477
--
2.13.3
7 years, 4 months