我想将以下更改应用于某人编写并提供diff
输出的某些代码。有没有办法仅给出以下输出,我可以轻松创建补丁并应用它,或者(因为它只有几行)我应该坚持手动进行更改?
即使排除下面的例子,如果这是一个很大的diff
输出,那么我真的想知道如果只给出这个,我可以把它输入patch
或类似的东西吗?
diff -r -c ganeti-2.5.1_orig/lib//constants.py
ganeti-2.5.1/lib//constants.py
*** ganeti-2.5.1_orig/lib//constants.py 2012-05-11 16:55:13.000000000 +0400
--- ganeti-2.5.1/lib//constants.py 2012-06-28 13:30:41.000000000 +0400
***************
*** 698,703 ****
--- 698,704 ----
HV_KVM_USE_CHROOT = "use_chroot"
HV_CPU_MASK = "cpu_mask"
HV_MEM_PATH = "mem_path"
+ HV_PASSTHROUGH = "pci_pass"
HV_BLOCKDEV_PREFIX = "blockdev_prefix"
HV_REBOOT_BEHAVIOR = "reboot_behavior"
***************
*** 743,748 ****
--- 744,750 ----
HV_KVM_USE_CHROOT: VTYPE_BOOL,
HV_CPU_MASK: VTYPE_STRING,
HV_MEM_PATH: VTYPE_STRING,
+ HV_PASSTHROUGH: VTYPE_STRING,
HV_BLOCKDEV_PREFIX: VTYPE_STRING,
HV_REBOOT_BEHAVIOR: VTYPE_STRING,
}
***************
*** 1280,1285 ****
--- 1282,1288 ----
HV_MIGRATION_MODE: HT_MIGRATION_NONLIVE,
HV_USE_LOCALTIME: False,
HV_BLOCKDEV_PREFIX: "hd",
+ HV_PASSTHROUGH: "",
HV_REBOOT_BEHAVIOR: INSTANCE_REBOOT_ALLOWED,
},
HT_KVM: {
diff -r -c ganeti-2.5.1_orig/lib//hypervisor/hv_xen.py
ganeti-2.5.1/lib//hypervisor/hv_xen.py
*** ganeti-2.5.1_orig/lib//hypervisor/hv_xen.py 2012-05-11
16:55:13.000000000 +0400
--- ganeti-2.5.1/lib//hypervisor/hv_xen.py 2012-06-28
13:30:43.000000000 +0400
***************
*** 579,585 ****
constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
# TODO: Add a check for the blockdev prefix (matching [a-z:] or
similar).
constants.HV_BLOCKDEV_PREFIX: hv_base.NO_CHECK,
! constants.HV_REBOOT_BEHAVIOR:
hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS)
}
--- 579,587 ----
constants.HV_USE_LOCALTIME: hv_base.NO_CHECK,
# TODO: Add a check for the blockdev prefix (matching [a-z:] or
similar).
constants.HV_BLOCKDEV_PREFIX: hv_base.NO_CHECK,
! #passthrough pci
! constants.HV_PASSTHROUGH: hv_base.NO_CHECK,
! constants.HV_REBOOT_BEHAVIOR:
hv_base.ParamInSet(True, constants.REBOOT_BEHAVIORS)
}
***************
*** 671,677 ****
disk_data.append(iso)
config.write("disk = [%s]\n" % (",".join(disk_data)))
!
config.write("on_poweroff = 'destroy'\n")
if hvp[constants.HV_REBOOT_BEHAVIOR] ==
constants.INSTANCE_REBOOT_ALLOWED:
config.write("on_reboot = 'restart'\n")
--- 673,684 ----
disk_data.append(iso)
config.write("disk = [%s]\n" % (",".join(disk_data)))
! # this is pci pass
! pci_pass = hvp[constants.HV_PASSTHROUGH]
! if pci_pass:
! pci_pass_arr = []
! pci_pass_arr = pci_pass.split("/")
! config.write("pci = %s \n" % pci_pass_arr)
config.write("on_poweroff = 'destroy'\n")
if hvp[constants.HV_REBOOT_BEHAVIOR] ==
constants.INSTANCE_REBOOT_ALLOWED:
config.write("on_reboot = 'restart'\n")
diff -r -c ganeti-2.5.1_orig/lib//query.py ganeti-2.5.1/lib//query.py
*** ganeti-2.5.1_orig/lib//query.py 2012-05-11 16:55:13.000000000 +0400
--- ganeti-2.5.1/lib//query.py 2012-06-28 13:30:43.000000000 +0400
***************
*** 1638,1643 ****
--- 1638,1644 ----
constants.HV_NIC_TYPE: "NIC_type",
constants.HV_PAE: "PAE",
constants.HV_VNC_BIND_ADDRESS: "VNC_bind_address",
+ constants.HV_PASSTHROUGH: "pci_pass",
}
fields = [
答案1
是的,您可以使用patch
此差异应用于文件。将其另存为foo.diff
并像这样应用:
patch < foo.diff